Header Ads Widget

Responsive Advertisement

Date formats in MySQL, SQL Server and Oracle (Comparisons)

Date formats comparisons in three databases:

  • MySQL
  • SQL Server
  • Oracle

Formats example date: 13 Mar , 2018

          Example                    MySQL Server              SQL Server                      Oracle              
2018
%Y
yyyy
YYYY
18
%y
yy
YY
March
%M
MMMM
MONTH
Mar
%b
MMM
MON
03
%m
MM
MM
Tue
%a
ddd
DY
13
%d
dd
DD

Examples for Testing

MySQL Server:

SELECT  DATE_FORMAT CURDATE( ) ,  '%d %b, %Y' )  AS CurrentDate; 

Output:




SQL Server:

SELECT  FORMAT GETDATE( ) , 'dd MMM, yyyy' ) AS CurrentDate;

Output:




Oracle:

SELECT  TO_CHAR ( SYSDATE 'DD Mon, YYYY' )  AS CurrentDate FROM TableName;

Output:




Post a Comment

0 Comments