Mysql Last_day Function

MySQL: LAST_DAY Function

This tutorial explains how to use the MySQL LAST_DAY function with syntax and examples.


The MySQL LAST_DAY function returns the last day of the month for a given date.


The syntax for the LAST_DAY function in MySQL is:

LAST_DAY( date_value )

Parameters or Arguments


The date or datetime value from which to extract the last day of the month.


  • 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 MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1


Let's look at some MySQL LAST_DAY function examples and explore how to use the LAST_DAY function in MySQL.

For example:

mysql> SELECT LAST_DAY('2014-01-13');
Output: '2014-01-31'

mysql> SELECT LAST_DAY('2014-02-09 08:21:05');
Output: '2014-02-28'

mysql> SELECT LAST_DAY('2016-02-17');
Output: '2016-02-29'

mysql> SELECT LAST_DAY('2014-3-15');
Output: '2014-03-31'

mysql> SELECT LAST_DAY(' 2014-2-16');
Output: 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).