Mysql Day Function

MySQL: DAY Function

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

Description

The MySQL DAY function returns the day portion of a date value.

Syntax

The syntax for the DAY function in MySQL is:

DAY( date_value )

Parameters or Arguments

date_value

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

Note

Applies To

The 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, MySQL 4.0, MySQL 3.23

Example

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

For example:

mysql> SELECT DAY('2014-01-28');
Output: 28

mysql> SELECT DAY('2014-01-28 15:21:05');
Output: 28

mysql> SELECT DAY('2013-10-15');
Output: 15

This last DAY example would display the day portion of the current system date (current system date is returned by the CURDATE function).

mysql> SELECT DAY(CURDATE());