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

MySQL EXTRACT Function

Example

Extract the month from a date:

SELECT EXTRACT(MONTH FROM "2017-06-15");

Definition and Usage

The EXTRACT() function extracts a part from a given date. Continue reading MySQL EXTRACT Function

MySQL DAYOFYEAR Function

Example

Return the day of the year for a date:

SELECT DAYOFYEAR("2017-06-15");

Definition and Usage

The DAYOFYEAR() function returns the day of the year for a given date (a number from 1 to 366). Continue reading MySQL DAYOFYEAR Function

MySQL DAYOFWEEK Function

Example

Return the weekday index for a date:

SELECT DAYOFWEEK("2017-06-15");

Definition and Usage

The DAYOFWEEK() function returns the weekday index for a given date (a number from 1 to 7).

Note: 1=Sunday, 2=Monday, 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday. Continue reading MySQL DAYOFWEEK Function

MySQL DAYOFMONTH Function

Example

Return the day of the month for a date:

SELECT DAYOFMONTH("2017-06-15");

Definition and Usage

The DAYOFMONTH() function returns the day of the month for a given date (a number from 1 to 31).

Continue reading MySQL DAYOFMONTH Function

MySQL DAYNAME Function

Example

Return the weekday name for a date:

SELECT DAYNAME("2017-06-15");

Definition and Usage

The DAYNAME() function returns the weekday name for a given date. Continue reading MySQL DAYNAME Function