The use of str_to_date functions in MySQL

Source: Internet
Author: User
Tags month name

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:

    1. %Y year
    2. %m Month
    3. %d days
    4. %H hours
    5. %i min
    6. %s seconds

Daquan

    1. %a Abbreviated Week name
    2. %b Abbreviated month name
    3. %c month, numeric
    4. %d Day of the month with English prefixes
    5. %d months of the day, value (00-31)
    6. %e Month Day, value (0-31)
    7. %f μs
    8. %H hours (00-23)
    9. %h hours (01-12)
    10. %I Hours (01-12)
    11. %i min, numeric (00-59)
    12. Day of the%j year (001-366)
    13. %k hours (0-23)
    14. %l hours (1-12)
    15. %M Month Name
    16. %m month, value (00-12)
    17. %p AM or PM
    18. %r time, 12-hour (Hh:mm:ss AM or PM)
    19. %s seconds (00-59)
    20. %s seconds (00-59)
    21. %T time, 24-hour (HH:MM:SS)
    22. %u week (00-53) Sunday is the first day of the week
    23. %u week (00-53) Monday is the first day of the week
    24. %V Week (01-53) Sunday is the first day of the week, with%x
    25. %v Week (01-53) Monday is the first day of the week, with%x
    26. %W Week Name
    27. %w Day of the week (0= Sunday, 6 = Saturday)
    28. %x year, of which Sunday was the first day of the week, 4-bit, with%V used
    29. %x year, of which Monday was the first day of the week, 4-bit, with%v used
    30. %Y year, 4 people
    31. %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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.