RE: [PHP] Re: sort by date
| From: | Mark Rees | Date: | Fri, 06 May 2005 09:17:29 +0000 |
| Subject: | RE: [PHP] Re: sort by date | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-214607@lists.php.net to get a copy of this message | ||
I strongly recommend that you convert the db column to the datetime datatype if at all possible.
However if you do wish to do it this way, read:
http://dev.mysql.com/doc/mysql/en/date-and-time-functions.html
And if you can't get it to work, bear in mind that STR_TO_DATE() is available as of MySQL
4.1.1.
-----Original Message-----
From: William Stokes [mailto:kalles@operamail.com]
Sent: 06 May 2005 08:23
To: php-general@lists.php.net
Subject: [PHP] Re: sort by date
Ok tested this and it won't work. Next question is sql question but
anyway...
Can I use STR_TO_DATE() or GET_FORMAT(DATE,'EUR') to query and sort dates
to web page as a date even if the data is just a string in the db? Probably
with GET_FORMAT(DATE,'EUR') it wont work cause it's a varchar field in the
DB.
Any idea how to put STR_TO_DATE() in to the following SQL query:
SELECT event_id,name,date,time,place,type,info FROM test_table WHERE (group = '$group')
AND (type = 'Game' OR type = 'training') ORDER BY date ASC
Thanks a lot
-Will
"William Stokes" <kalles@operamail.com> kirjoitti
viestissä:20050506054152.86469.qmail@lists.php.net...
> Hello,
>
> I made a mistake and stored date information to DB as varchar values
> (dd.mm.yyy). When I read the DB is it still possible to sort the data by
> date with SQL query (ORDER BY date ASC)? Or is it nessessary to have the
> date information to be stored as a date in the DB? Will it work or is the
> output going to be sorted randomly?
>
> Thanks
> -Will
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Gamma Global : Suppliers of HPCompaq, IBM, Acer, EPI, APC, Cyclades, D-Link, Cisco, Sun
Microsystems, 3Com
GAMMA GLOBAL (UK) LTD IS A RECOGNISED 'INVESTOR IN PEOPLE' AND AN 'ISO 9001
2000' REGISTERED COMPANY
**********************************************************************
CONFIDENTIALITY NOTICE:
This Email is confidential and may also be privileged. If you are not the
intended recipient, please notify the sender IMMEDIATELY; you should not
copy the email or use it for any purpose or disclose its contents to any
other person.
GENERAL STATEMENT:
Any statements made, or intentions expressed in this communication may not
necessarily reflect the view of Gamma Global (UK) Ltd. Be advised that no content
herein may be held binding upon Gamma Global (UK) Ltd or any associated company
unless confirmed by the issuance of a formal contractual document or
Purchase Order, subject to our Terms and Conditions available from http://www.gammaglobal.com
E&OE
**********************************************************************
**********************************************************************