Re: SQL prob (DATE_FORMAT)
| From: | George Pitcher | Date: | Fri, 05 Jul 2002 06:52:24 +0000 |
| Subject: | Re: SQL prob (DATE_FORMAT) | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-20328@lists.php.net to get a copy of this message | ||
Russ,
I'm a bit of a novice, but I would have thought that the DATE_FORMAT
function would only work if the field had been defined as a DATE field type.
If you are storing the date as an integer eg: 20020705 (today), why not
format your current date as a variable based on the same method? That should
produce the same results. You only need to format the output but you can do
that with PHP.
HTH
George
----- Original Message -----
From: "Russ" <russ@itomic.dns2go.com>
To: "PHP DB Mailing List (E-mail)" <php-db@lists.php.net>
Sent: Friday, July 05, 2002 7:33 AM
Subject: [PHP-DB] SQL prob (DATE_FORMAT)
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)
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php