LAST_DAY()

Overview

Returns a date string representing the last day of the month specified by a DATE or DATETIME argument.

USAGE

LAST_DAY(date)

Argument Name

Description

date

The DATE or DATETIME to evaluate

DETAILS

  • LAST_DAY() is date-time function that returns a date string representing the last day of the month for the specified date.

  • The argument can be an actual DATE or DATETIME type, a string in the format YYYY-MM-DD or YYYY-MM-DD hh:mm:ss, or a numeric value in the format YYYYMMDD or YYYYMMDDhhmmss.

  • In string context the return value is a string with the format YYYY-MM-DD while in numeric context the return value is a number with the format YYYYMMDD.

  • A NULL is returned if the argument is NULL or otherwise invalid.

SYNONYMS

SCHEMA

PARAMETERS

SKYSQL

PRIVILEGES

EXAMPLES

SELECT LAST_DAY('2018-02-01') AS 'Feb 2018',
       LAST_DAY('2020-02-01 12:34:56') AS 'Feb 2020',
       LAST_DAY(20200102) AS 'Jan 2020',
       LAST_DAY(20201108123456) AS 'Nov 2020',
       LAST_DAY('2020-02-30') AS 'Bad Day';
+------------+------------+------------+------------+---------+
| Feb 2018   | Feb 2020   | Jan 2020   | Nov 2020   | Bad Day |
+------------+------------+------------+------------+---------+
| 2018-02-28 | 2020-02-29 | 2020-01-31 | 2020-11-30 | NULL    |
+------------+------------+------------+------------+---------+
SELECT CONCAT('The last day in February 1900 was: ',
         LAST_DAY('1900-02-01') % 100) AS result;
+---------------------------------------+
| result                                |
+---------------------------------------+
| The last day in February 1900 was: 28 |
+---------------------------------------+

ERROR HANDLING

FEATURE INTERACTION

RESPONSES

DIAGNOSIS

ISO 9075:2016

CHANGE HISTORY

Release Series

History

23.09

  • Present starting in MariaDB Xpand 23.09.1.

6.1

  • Present starting in MariaDB Xpand 6.1.0.

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.0

  • Present starting in MariaDB Xpand 6.0.3.

5.3

  • Present starting in MariaDB Xpand 5.3.13.

Release Series

History

6.1

  • Present starting in MariaDB Xpand 6.1.0.

EXTERNAL REFERENCES