MariaDB: LAST_DAY Function
This MariaDB tutorial explains how to use the MariaDB LAST_DAY function with syntax and examples.
Description
The MariaDB LAST_DAY function returns the last day of the month for a given date.
Syntax
The syntax for the LAST_DAY function in MariaDB is:
LAST_DAY( date_value )
Parameters or Arguments
- date_value
- A date or datetime value from which to extract the last day of the month.
Note
- If date_value is not a valid date or datetime value, the LAST_DAY function would return NULL.
Applies To
The LAST_DAY function can be used in the following versions of MariaDB:
- MariaDB 10
Example
Let's look at some MariaDB LAST_DAY function examples and explore how to use the LAST_DAY function in MariaDB.
For example:
SELECT LAST_DAY('2014-05-21'); Result: '2014-05-31' SELECT LAST_DAY('2014-06-02 11:24:05'); Result: '2014-06-30' SELECT LAST_DAY('2014-02-19'); Result: '2014-02-28' SELECT LAST_DAY('2016-02-19'); Result: '2016-02-29' SELECT LAST_DAY('TechOnTheNet.com: 2014-05-21'); Result: NULL
This last LAST_DAY example would display the last day of the month for the current system date (current system date is returned by the CURDATE function).
SELECT LAST_DAY(CURDATE());
Advertisements