Click to See Complete Forum and Search --> : can i make date comparing query where i'm storing date as string data type


mukta
01-16-2008, 04:07 PM
can i make date comparing query where i'm storing date as string data type?

I have a field and its data type is string. Can i make a mysql query to cmpare date?

chazzy
01-16-2008, 08:18 PM
of course you can, but why not just store it as a date in the first place?

felgall
01-16-2008, 08:36 PM
If your date string is not in the order year month day then extracting the parts of the date in order to compare them in the right order gets complicated and involves multiple function calls inside the select. It is far more efficient to use a date field and then used FORMAT_DATE() in the selectto extract the date in whatever format you want.

mattyblah
01-17-2008, 01:57 AM
can you not cast the value to a date then make the comparison?