MySQL and Oracle date formatting character table

Source: Internet
Author: User
Tags month name

MySQL and Oracle date formatting character table

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.

My Sina Weibo: http://weibo.com/yzsind

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.