Use of the str_to_date (Str,format) function
The Str_to_date function converts STR into date-based data, and format represents the converted format.
Format parameter formats:
Common:
- %Y year
- %m Month
- %d days
- %H hours
- %i min
- %s seconds
Daquan
- %a Abbreviated Week name
- %b Abbreviated month name
- %c month, numeric
- %d Day of the month with English prefixes
- %d months of the day, value (00-31)
- %e Month Day, value (0-31)
- %f μs
- %H hours (00-23)
- %h hours (01-12)
- %I Hours (01-12)
- %i min, numeric (00-59)
- Day of the%j year (001-366)
- %k hours (0-23)
- %l hours (1-12)
- %M Month Name
- %m month, value (00-12)
- %p AM or PM
- %r time, 12-hour (Hh:mm:ss AM or PM)
- %s seconds (00-59)
- %s seconds (00-59)
- %T time, 24-hour (HH:MM:SS)
- %u week (00-53) Sunday is the first day of the week
- %u week (00-53) Monday is the first day of the week
- %V Week (01-53) Sunday is the first day of the week, with%x
- %v Week (01-53) Monday is the first day of the week, with%x
- %W Week Name
- %w Day of the week (0= Sunday, 6 = Saturday)
- %x year, of which Sunday was the first day of the week, 4-bit, with%V used
- %x year, of which Monday was the first day of the week, 4-bit, with%v used
- %Y year, 4 people
- %y year, 2 people
Instance:
Select str_to_date ('2017/01/02'%y/%m/%d');
Output Result:
. - on - Geneva
Precautions:
The location of the month and day can be transferred, but be sure to note the format of the case!!! Be sure to note the case of format!!! Be sure to note the case of format!!!
Important thing to say three times, eh, yes!
The use of str_to_date functions in MySQL