MySQL function-date time function

Source: Internet
Author: User

Curdate (), current_date () returns the current date ' yyyy-mm-dd '

Curtime (), Current_time () returns the current time ' HH:MM:SS '

Current_timestamp ()

LocalTime ()

Now ()

Sysdate () returns the current date and time ' Yyyy-mm-dd HH:MM:SS '

Unix_timestamp (date) returns the number of seconds after the Unix timestamp 1970-01-01 00:00:00, date can be a specified time, such as a date string, a DateTime string, a TIMESTAMP string, and so on

From_unixtime (date) converts a Unix timestamp to a normal format, with Unix_timestamp (date) Reciprocal functions

Utc_date () returns the current UTC (World standard Time) Date value

Utc_time () returns the current UTC time Value

--8 hours difference

Month (date) returns date 1-12

MONTHNAME (date) Returns the month of the date in English full name

Dayname (date) returns the English name of the day of the week that corresponds to date

DAYOFWEEK (date) returns the index position of date in the week, Sunday ... 7-Saturday

WEEKDAY (date) returns the index position of date in the week 0-Monday 6-Sunday

--Above 2017-07-03 for Monday

WEEK (date) returns date in the first week of the year, and can have a second parameter that determines whether it starts in Monday or Sunday and returns the return value of 0~53 or 1~53

WeekOfYear (date) returns date in the first week of the year

DayOfYear (date) returns the date of day of the year in the range 1~366

DayOfMonth (date) Returns date is the day of the one month return 1~31

Year (date) returns the years of the date---00-69 returns 2000~2069 70-99 returns 1970~1999

QUARTER (date) returns the first quarter of the 1~4

MINUTE (time) returns the number of minutes of time

SECOND (time) returns the number of seconds in time

EXTRACT (type from date) returns the type value extracted from date

Time_to_sec (time) returns the number of seconds to convert time

Sec_to_time (SEC) returns the result of converting seconds to hours minutes seconds

Date_add (Date,interval expr type)

Adddate (Date,interval expr type) adds an operation to the date

Date_sub (Date,interval expr type)

Subdate (Date,interval expr type) to reduce the operation of the date

Addtime (date,expr) date-is a date or time expression, expr-returns the result of date plus expr time for a time expression

Subtime (date,expr) returns the date minus expr time

DATEDIFF (DATE1,DATE2) returns the day value of Date1-date2

Date_format (Date,format) returns a date value in the format specified by format

Time_format (Time,format) returns the time value in format

Get_format (Val_type,format_type)

Val_type--date, Datetiem, time

Format_type--eur, INTERVAL, ISO, JIS, USA

Returns the appropriate format formatting

MySQL function-date time function

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.