MySQL: DAYOFMONTH Function

  • Post author:
  • Post category:MySQL
  • Post comments:1 Comment
MySQL DAYOFMONTH Function

In this guide, we will explain how to use the MySQL DAYOFMONTH function with syntax and examples.

Description

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

Syntax

The syntax for the DAYOFMONTH function in MySQL is:

DAYOFMONTH( date_value )

Parameters or Arguments

date_value

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

Note

  • The DAYOFMONTH function returns the day of the month (a number from 1 to 31) given a date value.
  • The DAY function is a synonym for the DAYOFMONTH function.

Applies To

The DAYOFMONTH function can be used in the following versions of :

  • 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 DAYOFMONTH function examples and explore how to use the DAYOFMONTH function.

For example:

mysql> SELECT DAYOFMONTH('2014-01-28');
Result: 28

mysql> SELECT DAYOFMONTH('2014-01-28 15:21:05');
Result: 28

mysql> SELECT DAYOFMONTH('2013-10-15');
Result: 15

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

mysql> SELECT DAYOFMONTH(CURDATE());

Next Topic : Click Here

This Post Has One Comment

Leave a Reply