MySQL LAST_DAY() Function
In MySQL, the LAST_DAY()
function returns the last day of the month for the specified date or datetime.
LAST_DAY()
Syntax
Here is the syntax of MySQL LAST_DAY()
function:
LAST_DAY(date)
Parameters
date
- Required. A date or datetime expression.
Return value
The MySQL LAST_DAY()
function returns the last day of the month for the specified date or datetime.
If the argument is an invalid date or NULL
, the LAST_DAY()
function will return NULL
.
LAST_DAY()
Examples
Here are some examples of the LAST_DAY()
function.
SELECT
LAST_DAY('2019-02-01'),
LAST_DAY('2020-02-01'),
LAST_DAY('2021-02-01'),
LAST_DAY('2022-02-01'),
LAST_DAY('2022-02-01 10:11:12')\G
LAST_DAY('2019-02-01'): 2019-02-28
LAST_DAY('2020-02-01'): 2020-02-29
LAST_DAY('2021-02-01'): 2021-02-28
LAST_DAY('2022-02-01'): 2022-02-28
LAST_DAY('2022-02-01 10:11:12'): 2022-02-28