Re: syntax
| From: | Jim Lucas | Date: | Wed, 25 Feb 2009 05:32:38 +0000 |
| Subject: | Re: syntax | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-288776@lists.php.net to get a copy of this message | ||
Jim Lucas wrote:
Terion Miller wrote:Well, looking a little closer, you will need to change a little more. Try this instead. The first should work, but if it doesn't match, try the second. " WHERE DATE_SUB(NOW(), INTERVAL 7 DAY) <=Problem with that example output is, is that a conversion has happened somewhere along the way. I say this because the MySQL timestamp format is YYYY-MM-DD HH:MM:SS. And depending on the full settings will probably include the GMT offset in there as well. So, your example is bad. As for saying that you use NOW() to populate it. Well, that says to me that you at least have something resembling a MySQL timestamp field in use. So, with that said, here is my rendition of what might work for you. Here is the example that I lifted from the MySQL doc site: http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html SELECT something FROM tbl_nameNobody has asked to confirm, but what format isHi Jim, stamp is a field in the db and I'm using the NOW() to populate it when a record is created and when I echo it to my excel sheet it looks like this: 2/24/2009 2:56:48 PMstamp? Unix Timestamp, MySQL Timestamp, MySQL Date stamp??? -- Jim Lucas "Some men are born to greatness, some achieve greatness,and some have greatness thrust upon them."Twelfth Night, Act II, Scene V by William Shakespeare-> WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= date_col;Taking that and changing it so it works for you would result in the following. $query .= " WHERE DATE_SUB(CURDATE(), INTERVAL 7 DAY) <=stamp"; Try that and let us know your results. */for the archives of course/* Jim Lucas
stamp";
or
" WHERE CONVERT(DATE_SUB(NOW(), INTERVAL 7 DAY), DATETIME) <= stamp";
also, check these to links out for more information:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add
http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html#function_convert