MySQL and Oracle date formatting character table

Source: Internet
Author: User

Both Oracle and mysql databases provide powerful date formatting formats. This article compares the formatting characters of the two databases for your reference:

Common Format String Mysql: DATE_FORMAT (now (), '% Y-% m-% d % H: % I: % s ')

Oracle:TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24: MI: ss ')

The following is a detailed list of formatting characters. The blank field indicates that no corresponding format exists:

Mysql

Oracle

Description

%

Dy
DY
Dy

Abbreviation of workday (Sun .. Sat)

% B

Mon
MON
Mon

Abbreviated month name (Jan .. Dec)

% C

MM

Month, digit format (0 .. 12)

% D

 

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

% D

DD

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

% E

 

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

% F

FF [6]

Microseconds (000000 .. 999999)

% H

HH24

Hour (00 .. 23)

% H

@ I

HH

Hour (01 .. 12)

% I

MI

Minute, digit format (00 .. 59)

% J

DDD

Days in a year (001 .. 366)

% K

 

Hour (0 .. 23)

% L

 

Hour (1 .. 12)

% M

Month
MONTH
Month

Month name (January... December)

% M

MM

Month, digit format (00 .. 12)

% P

AM
PM

AM or PM)

% R

 

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

% S

SS

Seconds (00 .. 59)

% S

SS

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

D

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

YYYY

Year, Number Format, 4-digit

% Y

YY

Year, Number Format (2 digits)

%

 

'%' Text character

 

SSSSS

The number of seconds that have elapsed since the day (0-86399)

 

Q

Quarter (1, 2, 3, 4)

 

RM
Rm
Rm

Rome numeric month (I-XII; JAN = I)

 

WW

Week (01 .. 52 ),Computing started in January 1

 

IW

Week (00 .. 53 ),The calculation starts from the first Monday and is counted as the first week of the previous year.

 

W

Week (1-5) in the month ),Calculated from the first day of every month

 

FF [1 .. 9]

Microseconds,The following number indicates the number of digits displayed.

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.