PDA

View Full Version : MySQL Help - Date Issues


noonespecial
01-09-2009, 06:43 AM
I have a column of dates (field93) in this format:

MMDDYY

Currently I am using:

ORDER BY field93 DESC

However, with the new year - this doesn't work because:

120108 shows up before 010709

How can I fix this?

Marco van Herwaarden
01-09-2009, 07:27 AM
You should not store it in this format. This is why most software stores date like (YY)YYMMDD, so it can be sorted.

Bellardia
01-09-2009, 12:34 PM
You should convert your dates like Marco said so you can use a reliable search method.
I can't think of any way to generally find what your looking for without searching for specific smal intervals.

Marco van Herwaarden
01-09-2009, 01:33 PM
Yes you could sort by substrings, but that could easily become a performence killer.