MySQL Date function

Source: Internet
Author: User
Tags month name

#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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.