MySQL MONTH Function

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)

Continue reading MySQL MONTH Function

MySQL MINUTE Function

Example

Return the minute part of a datetime value:

SELECT MINUTE("2017-06-20 09:34:00");

Definition and Usage

The MINUTE() function returns the minute part of a time/datetime (from 0 to 59).

Syntax

MINUTE(datetime)

Continue reading MySQL MINUTE Function

MySQL MICROSECOND Function

Example

Return the microsecond part of a datetime:

SELECT MICROSECOND("2017-06-20 09:34:00.000023");

Definition and Usage

The MICROSECOND() function returns the microsecond part of a time/datetime (from 0 to 999999). Continue reading MySQL MICROSECOND Function

MySQL MAKETIME Function

Example

Create and return a time value based on an hour, minute, and second value:

SELECT MAKETIME(11, 35, 4);

Definition and Usage

The MAKETIME() function creates and returns a time based on an hour, minute, and second value.

Syntax

MAKETIME(hour, minute, second)

Continue reading MySQL MAKETIME Function

MySQL MAKEDATE Function

Example

Create and return a date based onĀ  a year and a number of days value:

SELECT MAKEDATE(2017, 3);

Definition and Usage

The MAKEDATE() function creates and returns a date based on a year and a number of days value. Continue reading MySQL MAKEDATE Function

MySQL LOCALTIMESTAMP Function

Example

Return current date and time:

SELECT LOCALTIMESTAMP();

Definition and Usage

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

MySQL LOCALTIME Function

Example

Return current date and time:

SELECT LOCALTIME();

Definition and Usage

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

MySQL LAST_DAY Function

Example

Extract the last day of the month for the given date:

SELECT LAST_DAY("2017-06-20");

Definition and Usage

The LAST_DAY() function extracts the last day of the month for a given date. Continue reading MySQL LAST_DAY Function

MySQL HOUR Function

Example

Return the hour part of a datetime:

SELECT HOUR("2017-06-20 09:34:00");

Definition and Usage

The HOUR() function returns the hour part for a given date (from 0 to 838). Continue reading MySQL HOUR Function

MySQL FROM_DAYS Function

Example

Return a date from a numeric representation of the day:

SELECT FROM_DAYS(685467);

Definition and Usage

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.

Continue reading MySQL FROM_DAYS Function