"MySQL" DATE and String conversions (Date_format & Str_to_date)

Source: Internet
Author: User

1.date--> String

Functions used: Date_format (date,format) Date: Dates to convert format: formatted style

Format Style collation:

Year: %Y display four-bit: %Y only show the latter two bits: 15

Month: %M Month in English display: October %M Month Arabic display: 01-12 %b Month in English thumbnail display: Oct %c Month Arabic display: 1-12

Day: %d Arabic display: 00-31 %d with English suffix: 1st-31th %e Arabic display: 1-31 %j days: 001-3 66

When: %H : 00-23 %H: 01-12 %I: 01-12 %k: 0-23 %l: 1-12

Points: %i: 00-59

Seconds: %s: 00-59 %s: 00-59

Subtlety: %f

AM/PM:%p

12-hour time:%r: 02:02:44 PM

24-hour time: %T: 14:02:44

Week: %W: Week's English display %W week Arabic display: 0 (Sunday)-6 (Saturday) %a Week's English thumbnail display: mon-

Eg:date_format (now (), "%y-%m-%d%T") 2015-09-01 17:10:52

Date_format (now (), "%y-%m-%d%h:%i:%s%p") 2015-09-01 17:10:52 PM

2.string-->date

Functions used: Str_to_date (Str,format) STR: Date in character format: Formatting style

Eg:str_to_date (' 1992-04-12 ', "%y-%m-%d") Output: 1992-04-12 (Date form)

"MySQL" DATE and String conversions (Date_format & Str_to_date)

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.