Re: syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jim Lucas wrote:
Terion Miller wrote:
Nobody has asked to confirm, but what format is `stamp`?

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

Hi 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
PM


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_name
    -> 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


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) <= `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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux