note 27701 deleted from function.date by sniper
| From: | sniper@php.net | Date: | Sat, 11 Oct 2003 16:51:18 +0000 |
| Subject: | note 27701 deleted from function.date by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58271@lists.php.net to get a copy of this message | ||
Note Submitter: paul at atomicrevs.net
----
There are several people here trying to add/subtract from timestamp values in MySQL. This *can*
work, but it can also go horribly wrong.
The correct way is to do something like this:
$query = "SELECT DISTINCT foo1, foo2, foo3 FROM
table WHERE TO_DAYS(NOW()) -
TO_DAYS(foo2) <= 7 ORDER BY foo2 ASC;"
MySQL then works out 7 days prior to NOW. Even if today was the 6th, for example.
Of course, if time was decimalised, things would be so much easier!