last day of month in mysql

Sometimes we need to get the last day of month in mysql because every month has different last day eg. FEB. may have 28 or 29, JAN has 31 and APR has 30.

MySQL provide us a function LAST_DAY()
returns the last day of the corresponding month for a date or datetime value. If the date or datetime value is invalid, the function returns NULL.

SYNTAX :

Here specificdate is any valid date.

Example :

The following statement will return the last date of the corresponding month of the given date 2014-10-09.

2.
The following statement will return the last date of the corresponding month of the given datetime 2014-10-09 15:45:53.

Last_Day() is an easy function to get last day of month in mysql.

You Might Interested In

Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.