Jump to content

[SOLVED] order by substring


Darkness Soul

Recommended Posts

//begin lament
Why oh why does everyone like to store dates as varchar?
//end lament

The "right" answer is store your dates as dates!
The answer you are looking for is:
[code]
ORDER BY FIELD(MID(myDateField,1,3),'JAN','FEB','MAR',...)
//where myDateField is well your date field in question.[/code]
str_to_date may help a lot, order by field too, but that database isn't mine, and the data storage there is a mess.. i found dates like jan/2005, fev/02, agos/2002, 05/2001.. it have no standard.. =S

thankx for the help

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.