--MySQL time date function type and use
--1, Day (), month (), year ()--Returns the number of days, months, and years of the specified date;
Select Day (Curdate ()) as ' date ' from dual;
Select Month (Curdate ()) as ' month ' from dual;
Select year (Curdate ()) as ' years ' from dual;
--2, now (), Current_timestamp (), localtime (), Localtimestamp () Take the time when the statement was executed
--Sysdate () takes a dynamic actual time
Select Current_timestamp (), SLEEP (3), localtime (), Localtimestamp (), now (), Curdate (), Sysdate () from DUAL;
Select Timediff (' 13:25:20 ', ' 10:20:30 ') from DUAL; --two time periods to subtract the resulting time
Select DateDiff (' 2014-02-01 ', ' 2012-05-12 ') from DUAL; --Returns the number of days between two dates
Select Date_add (' 2016-05-24 ', INTERVAL 5 years) from dual;--adds a specified time interval to the date
Select Date_sub (' 2016-05-24 ', INTERVAL 5 years) from the dual;--function subtracts the specified time interval from the date
Select Date_format (Curdate (), '%y-%m-%d ') from the dual--function is used to display date/time data in different formats.
MySQL time date function type and use