Literals: Date and Time

In MySQL programming, 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 1

snippet
select id, name, salary, date_format(sal_date,'%d-%m-%y') as new_date_formate from staff1;
MySQL Date and Time

Example 2

snippet
select id, name, salary, date_format(sal_date,'%d%m%y') as new_date_formate from staff1;
MySQL Date and Time
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +