I am working with a MySQL database where dates are stored as varchar like this:
'2013-01-31' in column cl_223
I need to select only records from 2013 so I tried:
SELECT ..
FROM ....
Where cl_223 Like '2013'
But that does not seem to work.
Thanks for all help!
Storing a datettime value in a varchar column complicates some functionality on date time operations. But of course you can select your values writing such a query as follow
But if you don’t have any performance issue you can convert the varchar column to a datetime value and write stronger typed query like this:
But if you need a date time value as a date time in your process you’d better store it in a datetime column instead of a varchar column.