MySQL string goto Date type
Select Str_to_date (' 2014-08-20 00:00:00 ', '%y-%m-%d%h:%i:%s ');
>2014-08-20 00:00:00
Select Date_format (' 1997-10-04 22:23:00 ', '%h:%i:%s ');
>22:23:00
Specifiers |
Description |
%a |
Abbreviated name of the weekday (Sun.. Sat) |
%b |
Abbreviated name of the month (Jan: DEC) |
%c |
month, digital form (0..12) |
%d |
Date of the month with English suffix (0th, 1st, 2nd, 3rd, ...) |
%d |
Date of the month, digital form (00..31) |
%e |
Date of the month, digital form (0..31) |
%f |
microseconds (000000..999999) |
%H |
Hours (00..23) |
%h |
Hours (01..12) |
%I |
Hours (01..12) |
%i |
Minutes, digital form (00..59) |
%j |
Number of days in the year (001..366) |
%k |
Hours (0..23) |
%l |
Hours (1..12) |
%M |
Month name (January): December) |
%m |
month, digital form (00..12) |
%p |
Morning (AM) or PM (PM) |
%r |
Time, 12 hours (hours hh: minutes mm: seconds SS after plus am or PM) |
%s |
Seconds (00..59) |
%s |
Seconds (00..59) |
%T |
Time, 24 hours (hours hh: minutes mm: Seconds ss) |
%u |
Week (00..53), where Sunday is the first day of the week |
%u |
Week (00..53), where Monday is the first day of the week |
%V |
Week (01..53), of which Sunday is the first day of the week; Simultaneous use with%x |
%v |
Week (01..53), of which Monday is the first day of the week; Simultaneous use with%x |
%W |
Weekday Name (Sunday: Saturday |
%w |
Daily of the Week (0= Sunday). 6= Saturday) |
%x |
The year of the week, of which Sunday is the first day of the week, the number form, 4 digits; and%v use simultaneously |
%x |
The year of the week, of which Monday is the first day of the week, the number form, 4 digits; and%v use simultaneously |
%Y |
Year, number form, 4 digits |
%y |
Year, digital form (2 digits) |
%% |
'% ' literal characters |
All other characters are copied into the result without explanation.
Note that the '% ' character is required before the format specifier.
The range of month and date specifiers starts from zero, because MySQL allows the storage of incomplete dates such as ' 2004-00-00 '.
This article is from the lava blog, so be sure to keep this source http://lavasoft.blog.51cto.com/62575/1541537
MySQL string goto Date type