This tutorial explains how to use the MySQL DAYOFMONTH function with syntax and examples.
The MySQL DAYOFMONTH function returns the day portion of a date value.
The syntax for the DAYOFMONTH function in MySQL is:
DAYOFMONTH( date_value )
The date or datetime value from which to extract the day of the month.
The DAYOFMONTH function can be used in the following versions of MySQL:
Let's look at some MySQL DAYOFMONTH function examples and explore how to use the DAYOFMONTH function in MySQL.
For example:
mysql> SELECT DAYOFMONTH('2014-01-28');
Output: 28
mysql> SELECT DAYOFMONTH('2014-01-28 15:21:05');
Output: 28
mysql> SELECT DAYOFMONTH('2013-10-15');
Output: 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());