Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

MySQL LAST_DAY Function

by suresh

MySQL LAST_DAY function is one of the MySQL Date Functions, which returns the last day of the month from the given date. Let us see how to use this LAST_DAY function to get the last day in a month in MySQL from an expression with an example.

The basic syntax of the LAST_DAY() Function in MySQL is as shown below:

LAST_DAY(date or expression);

MySQL LAST_DAY function Example

These MySQL examples help you understand the use of last day function. Here, we are returning the last day of the month from different date expressions.

SELECT LAST_DAY('2017-01-01');

SELECT LAST_DAY('2018-06-14');

SELECT LAST_DAY('2018-09-14');

OUTPUT

MySQL LAST_DAY Function 1

Let us see another example of the MySQL LAST DAY function. Here, we are returning the last day of the month from the current date and time returned by the Now() and CURDATE() function.

SELECT LAST_DAY(NOW()), LAST_DAY(CURRENT_DATE());

OUTPUT

MySQL LAST_DAY Function 2

MySQL LAST_DAY Function Example 2

The following Date Function queries show you what happens when we try to return the day of year value from string date or invalid dates.

SELECT LAST_DAY(NOW() + 22);

SELECT LAST_DAY('2018-06-32');

SELECT LAST_DAY(CURDATE() + 22);

OUTPUT

MySQL LAST_DAY Function 3

From the above screenshot, LAST_DAY(‘2018-06-32’); statement returned NULL. Because it’s an invalid MySQL date.

Within the Last statement, LAST_DAY(CURDATE() + 22); means, LAST_DAY(‘2019-02-33’);. Again, it’s an invalid date.

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy