I have a string
column which acts as a date
and I want to select it as a date
.
Is it possible?
My sample data format would be; month/day/year
-> 12/31/2011
I have a string
column which acts as a date
and I want to select it as a date
.
Is it possible?
My sample data format would be; month/day/year
-> 12/31/2011
Here's another two examples.
To output the day, month, and year, you can use:
Which produces:
To also output the time, you can use:
Which produces:
As was told at MySQL Using a string column with date text as a date field, you can do
You can also handle these date strings in
WHERE
clauses. For exampleYou can handle all kinds of date/time layouts this way. Please refer to the format specifiers for the
DATE_FORMAT()
function to see what you can put into the second parameter ofSTR_TO_DATE()
.http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
use the above page to refer more Functions in MySQL
say for example use the below query to get output
For String format use the below link
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format