Function Reference

DAY

PostgreSQL equivalent:

Returns the day of the month of a date.

MySQL 8.1
DAY(date)

Parameters

dateDATE
Date or datetime

Return value

An integer from 1 to 31; 0 for a date with a zero day, for example 2022-00-00; NULL if the value is not recognized as a date

Examples

Day of the month from a date

MySQL 8.1
SELECT DAY('2022-06-16');
DAY('2022-06-16')
16

Day of the month for payments

MySQL 8.1
SELECT payment_id,
	date,
	DAY(date) AS day_of_month
FROM Payments;
payment_iddateday_of_month
12005-02-1212
22005-03-2323
32005-05-1414
42005-07-2222
52005-07-2626
62005-02-2020
72005-07-3030
82005-09-1212
92005-09-3030
102005-10-2727

Details

The function is a synonym for DAYOFMONTH.

See also