MySQL string to date type

Source: Internet
Author: User
Tags month name
MySQL string to date type selectstr_to_date (2014-08-2000:00:00, % Y-% m-% d % H: % I: % s); 2014-08-2000: 00: 00selectdate_format (1997-10-0422: 23: 00, % H: % I: % s); 22:23:00 description % a workday abbreviation name (Sun .. sat) % B abbreviated name of the month (Jan .. de

MySQL string to date type select str_to_date ('2017-08-20 00:00:00 ',' % Y-% m-% d % H: % I: % s '); 1997 00:00:00 select date_format ('2017-10-04 22:23:00 ',' % H: % I: % s'); 22:23:00 specifier % a workday abbreviation name (Sun .. sat) % B abbreviated name of the month (Jan .. de

MySQL string to date type


Select str_to_date ('2017-08-20 00:00:00 ',' % Y-% m-% d % H: % I: % s ');

> 00:00:00


Select date_format ('2017-10-04 22:23:00 ',' % H: % I: % s ');

> 22:23:00


Description

Description

%

Abbreviation of workday (Sun .. Sat)

% B

Abbreviated month name (Jan .. Dec)

% C

Month, digit format (0 .. 12)

% D

Date of the month with English suffix (0th, 1st, 2nd, 3rd ,...)

% D

The date of the month, in the numeric format (00 .. 31)

% E

The date of the month, in the numeric format (0 .. 31)

% F

Microseconds (000000 .. 999999)

% H

Hour (00 .. 23)

% H

Hour (01 .. 12)

% I

Hour (01 .. 12)

% I

Minute, digit format (00 .. 59)

% J

Days in a year (001 .. 366)

% K

Hour (0 .. 23)

% L

Hour (1 .. 12)

% M

Month name (January... December)

% M

Month, digit format (00 .. 12)

% P

AM or PM)

% R

Time, in 12-hour format (hour hh: minute mm: seconds ss plus AM or PM)

% S

Seconds (00 .. 59)

% S

Seconds (00 .. 59)

% T

Time, in 24-hour format (hour hh: minute 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), where Sunday is the first day of the week; and % X is used at the same time

% V

Week (01 .. 53), where Monday is the first day of the week; use both % x

% W

Workday name (Sunday... Saturday)

% W

Daily in a week (0 = Sunday .. 6 = Saturday)

% X

The year of the week, in which Sunday is the first day of the week, in the form of a number, 4 digits; and % V at the same time

% X

The year of the week, where Monday is the first day of the week, in the form of a number, 4 digits; used together with % v

% Y

Year, Number Format, 4-digit

% Y

Year, Number Format (2 digits)

%

'%' Text character

All other characters are copied to the result without explanation.

Note that the '%' character must be before the format specified.

The range of month and date specifiers starts from scratch because MySQL allows storage of incomplete dates such as '2017-00-00.

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.