Summary of MySQL date functions

Source: Internet
Author: User

This article mainly tells you about MySQL date functions. We all know that the proportion of MySQL date functions used in actual operations is still the majority, therefore, it is necessary to have a good understanding of its related aspects. The following article describes its specific content.

ADDTIME (date2, time_interval) // Add time_interval to date2

CONVERT_TZ (datetime2, fromTZ, toTZ) // convert the time zone

CURRENT_DATE () // current date

CURRENT_TIME () // current time

CURRENT_TIMESTAMP () // current Timestamp

DATE (datetime) // return the DATE part of datetime

DATE_ADD (date2, INTERVAL d_value d_type) // Add a date or time in date2

DATE_FORMAT (datetime, FormatCodes) // display datetime in formatcodes format

DATE_SUB (date2, INTERVAL d_value d_type) // subtract a time from date2

DATEDIFF (date1, date2) // two date differences

DAY (date) // returns the DAY of the date

DAYNAME (date) // english week

DAYOFWEEK (date) // Week (1-7), 1 is Sunday

DAYOFYEAR (date) // The day of the year

EXTRACT (interval_name FROM date) // EXTRACT the specified part of the date FROM date

MAKEDATE (year, day) // specifies the day of the year and the day of the year.

MySQL date function, period string

MAKETIME (hour, minute, second) // generate a time string

MONTHNAME (date) // name of the English month

NOW () // current time

SEC_TO_TIME (seconds) // converts seconds to time

STR_TO_DATE (string, format) // converts a string to a time value. The format is displayed.

TIMEDIFF (datetime1, datetime2) // two time difference

TIME_TO_SEC (time) // time to seconds]

WEEK (date_time [, start_of_week]) // WEEK

YEAR (datetime) // YEAR

DAYOFMONTH (datetime) // The day of the month

HOUR (datetime) // HOUR

LAST_DAY (date) // the last date of the Month of date

MICROSECOND (datetime) // MICROSECOND

MONTH (datetime) // MONTH

MINUTE (datetime) // MINUTE

The above content is an introduction to the MySQL date function. I hope you will get some benefits.

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.