Example
Return the month part of a date:
SELECT MONTH("2017-06-15");
Definition and Usage
The MONTH() function returns the month part for a given date (a number from 1 to 12).
Syntax
MONTH(date)
Return the month part of a date:
SELECT MONTH("2017-06-15");
The MONTH() function returns the month part for a given date (a number from 1 to 12).
MONTH(date)
Return the minute part of a datetime value:
SELECT MINUTE("2017-06-20 09:34:00");
The MINUTE() function returns the minute part of a time/datetime (from 0 to 59).
MINUTE(datetime)
Return the microsecond part of a datetime:
SELECT MICROSECOND("2017-06-20 09:34:00.000023");
The MICROSECOND() function returns the microsecond part of a time/datetime (from 0 to 999999). Continue reading MySQL MICROSECOND Function
Create and return a time value based on an hour, minute, and second value:
SELECT MAKETIME(11, 35, 4);
The MAKETIME() function creates and returns a time based on an hour, minute, and second value.
MAKETIME(hour, minute, second)
Create and return a date based onĀ a year and a number of days value:
SELECT MAKEDATE(2017, 3);
The MAKEDATE() function creates and returns a date based on a year and a number of days value. Continue reading MySQL MAKEDATE Function
Return current date and time:
SELECT LOCALTIMESTAMP();
The LOCALTIMESTAMP() function returns the current date and time.
Note: The date and time is returned as “YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric). Continue reading MySQL LOCALTIMESTAMP Function
Return current date and time:
SELECT LOCALTIME();
The LOCALTIME() function returns the current date and time.
Note: The date and time is returned as “YYYY-MM-DD HH-MM-SS” (string) or as YYYYMMDDHHMMSS.uuuuuu (numeric). Continue reading MySQL LOCALTIME Function
Extract the last day of the month for the given date:
SELECT LAST_DAY("2017-06-20");
The LAST_DAY() function extracts the last day of the month for a given date. Continue reading MySQL LAST_DAY Function
Return the hour part of a datetime:
SELECT HOUR("2017-06-20 09:34:00");
The HOUR() function returns the hour part for a given date (from 0 to 838). Continue reading MySQL HOUR Function
Return a date from a numeric representation of the day:
SELECT FROM_DAYS(685467);
The FROM_DAYS() function returns a date from a numeric datevalue.
The FROM_DAYS() function is to be used only with dates within the Gregorian calendar.