#now (), gets the date format of the current timestamp [' y-m-d h:i:s '] #sysdate (). Gets the date format of the current timestamp [' y-m-d h:i:s ']select now () select Sysdate (); #curdate () Gets the date format for the current timestamp [' y-m-d '] current_date () Select Curdate (), select Current_date (), #curtime ()/current_time get the time format of the current timestamp [' H : I:s ']select curtime (); select Current_time (); # Get current UTC (Greenwich time) datetime function: Utc_date (), Utc_time (), Utc_timestamp () Select Utc_time (), Utc_date (), Utc_timestamp () #dayofweek (date) Gets the day of the week that belongs to the week of the #dayofmonth () gets the date in January that belonged to the first day of #dayofyear () Gets the date in a year that belongs to the day of the Select DayOfWeek (' 2014-11-17 ') Select DayOfMonth (' 2014-11-17 ') Select DayOfYear (' 2014-11-17 ') #5. MySQL returns the week and month name functions: Dayname (), MonthName () Select Dayname (), select MonthName (), #last_day () returns the date of the last day in the month select Last_ Day (' 2014-11-17 '); the #date_add (now (), SSS) returns a date that has been set to add select Date_add (' 2014-11-17 ', Interval 2 days) Select Date_add (' 2014-11-17 ', Interval 1 week) #date_sub (now (), SSS) returns a date that reduces a specific setting for select Date_sub (' 2014-11-17 ', Interval 2 day) #period_ diff (Date1,date2) compares two months Period_diff (201411,201408), #unix_timestamp () Gets the current timestamp select Unix_timestamp (); #frOm_unixtime () Converts the timestamp to the date format select From_unixtime (Unix_timestamp (), '%y-%m-%d '); #date_format格式化日期格式select date_format ( Now (), '%y-%m-%d ');
MySQL Date function