LAST_DAY() FUNCTION in MySQL

LAST_DAY() FUNCTION
The MySQL LAST_DAY function is used to get the last day of the month for a date or datetime value. The various versions of MySQL support the LAST_DAY function, namely, MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0 and MySQL 4.1.1.

Syntax:

LAST_DAY( expression )

Parameters:

expression: It is used to specify the date or datetime value.

Example 1:

mysql> SELECT LAST_DAY ('2019-07-05');

Output:

'2019-07-31'

Explanation:

The last day of the month has been returned for the given date.

Example 2:

mysql> SELECT LAST_DAY ('2019-07-05 15:30:20');

Output:

'2019-07-31'

Explanation:

The last day of the month has been returned for the given datetime.