Table of Contents
Learn – MySQL Date & Time
In MySQL database, the sql for Date and Time literals are in the form of strings or numbers.
Following are some more formats in which date and time can be displayed.
EXAMPLE FORMAT
‘2018-10-18’ ‘YYYY-MM-DD’
‘20181018’ ‘YYYYMMDD’
20181018 YYYYMMDD
’18-10-18′ ‘YY-MM-DD’
181018 YYMMDD
‘2018-10-18 5:
25:
20′ ‘YYYY-MM-DD HH:
MM:
SS’
‘2018101852520’ ‘YYYYMMDDHHMMSS’
2018101852520 YYYYMMDDHHMMSS
’18-10-18 5:
25:
20′ ‘YY-MM-DD HH:
MM:
SS’
‘18101852520’ ‘YYMMDDHHMMSS’
18101852520 YYMMDDHHMMSS
Example Query
select id, name, salary, date_format(paydate,'%d-%m-%y') as date from emp;
select id, name, salary, date_format(paydate,'%d%m%y') as date from emp;