Forums
This topic is locked
Not ordering by date.
Posted 21 Sep 2004 22:53:56
1
has voted
21 Sep 2004 22:53:56 Simon Bloodworth posted:
i have a simple database for a news section site. there is a date from column and i would like to be able to order the results by this. but if say 2 dates in the DB were 25/09/04 and 30/05/01 it would order by the first 2 digits so the 30th date would show first?!how can i get it to look at the whole date field and not just the first 2 digits or before the /?
Any help would be greatly appreciated.
Regards
Simon
Replies
Replied 22 Sep 2004 11:18:31
22 Sep 2004 11:18:31 Lee Diggins replied:
Hi Simon
Is the date field a datetime datatype?
Considering the two dates you would expect the dates to be returned in the order you've given, 30/05/01 comes before 25/09/04.
You need to add an:
order by myDateField DESC
making the most recent dates appear at the top of the list
Digga
Sharing Knowledge Saves Valuable Time!!!
Edited by - Digga the Wolf on 22 Sep 2004 11:19:17
Is the date field a datetime datatype?
Considering the two dates you would expect the dates to be returned in the order you've given, 30/05/01 comes before 25/09/04.
You need to add an:
order by myDateField DESC
making the most recent dates appear at the top of the list
Digga
Sharing Knowledge Saves Valuable Time!!!
Edited by - Digga the Wolf on 22 Sep 2004 11:19:17
Replied 22 Sep 2004 22:23:56
22 Sep 2004 22:23:56 Simon Bloodworth replied:
hi digga,
not sure by what you mean datetime datatype -
I have in my sql as you suggest but it still only looks at the first 2 digits and not past the /.
I appreciate your help
Simon
not sure by what you mean datetime datatype -
I have in my sql as you suggest but it still only looks at the first 2 digits and not past the /.
I appreciate your help
Simon
Replied 22 Sep 2004 22:32:13
22 Sep 2004 22:32:13 Simon Bloodworth replied:
UPDATE!
Finally got what you mean now! Found out the actual field in my database was set to Text, not Date/Time. Changed that and is working like a dream now.
Thanks for your help.
Finally got what you mean now! Found out the actual field in my database was set to Text, not Date/Time. Changed that and is working like a dream now.
Thanks for your help.