Reputation: 2056
I have been trying to convert this date 5-Jan-76
with sql in Jan, 05 1976
and i tried following methods but they returned null
kindly let me know what wrong with the following query?:
select STR_TO_DATE('5-Jan-76', '%M,%d %Y')
select DATE_FORMAT('5-Jan-76','%M,%d %Y')
Upvotes: 0
Views: 87
Reputation: 272066
Your first approach was correct but you did not use the right format specifiers:
%b
Abbreviated month name (Jan..Dec)
%d
Day of the month, numeric (00..31)
%e
Day of the month, numeric (0..31)
%Y
Year, numeric, four digits
%y
Year, numeric (two digits)
Here is what you need to do:
SELECT DATE_FORMAT(STR_TO_DATE('5-Jan-76', '%e-%b-%y'), '%b, %d %Y'); -- Jan, 05 1976
Upvotes: 5