SQL prob (DATE_FORMAT)
| From: | Russ | Date: | Fri, 05 Jul 2002 06:33:58 +0000 |
| Subject: | SQL prob (DATE_FORMAT) | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-20327@lists.php.net to get a copy of this message | ||
Hi all:
Thanks to Jason for his pointers - whatever the reason though, we need
to use INT(10) for our CMS to work! ;-) Anyways...
Using our MySQL INT(10) field the following query isn't behaving itself:
$event_sql = "SELECT *,DATE_FORMAT('EventDate','%Y-%m-%d') FROM events
WHERE EventDate>=CURDATE() ORDER BY EventDate DESC LIMIT 3";
This query should only return those event entries of today's date and
any future date right?
The MySQL manual points out that: CURDATE() returns dates thus:
mysql> SELECT CURDATE(); ->
'1997-12-15' (i.e.: with hyphens between the entities in the same
format as my DATE_FORMAT() arg's specify above)
Can anyone point out why the results of the queries continue to output
entries whose dates are prior to the value of CURDATE()? Do these
functions depend upon DATETIME, DATE, TITMESTAMP (etc) MySQL field types
or what??
Cheers all.
Russ
Mr Russ Michell
Web Applications Developer
Itomic.com
Email: russ@itomic.com
Tel: +61 (0)8 9321 3844
Fax: +61 (0)8 6210 1364
Post: PO Box 228, Innaloo, WA 6918, Australia
Street: Suite 24, 158 William St, Perth, WA 6000, Australia
"No proof of existence is not proof of non-existence."
(Physicist: Stanton T. Friedman on Debunking Ufology)