Name

LAST_DAY()

Synopsis

LAST_DAY(date)

Returns the last day of the month for the given DATETIME value date. If the argument is invalid, it returns NULL. This code:

SELECT LAST_DAY('2016-02-03');
SELECT LAST_DAY('2016-03-11');
SELECT LAST_DAY('2016-04-26');

returns the following values:

2016-02-29
2016-03-31
2016-04-30

As you’d expect, it correctly returns the 28th day of February, the 31st of March, and the 30th of April 2011.

Get Learning PHP, MySQL, JavaScript, and CSS, 2nd Edition 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.