Name

LAST_DAY( )

Synopsis

LAST_DAY(date)

This function returns the date of the last day of the month for a given date. This function is available as of Version 4.1.1 of MySQL.

SELECT LAST_DAY('2005-12-15')
   AS 'End of Month';
+--------------+
| End of Month |
+--------------+
| 2005-12-31   |
+--------------+

This function is more meaningful when you apply it to a date column where the date is unknown before entering the SQL statement.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.