Function Reference

MAKEDATE

Returns a date from a year and a day number within that year.

MySQL 8.1
MAKEDATE(year, dayofyear)

Parameters

yearINT
Year
dayofyearINT
Day number within the year, starting from 1

Return value

A date (DATE); a day number beyond the length of the year moves the date into the following years; NULL if the day number is less than 1

Examples

Date from a year and a day

MySQL 8.1
SELECT MAKEDATE(2025, 156);
MAKEDATE(2025, 156)
2025-06-05

Day number beyond the year

MySQL 8.1
SELECT MAKEDATE(2025, 366);
MAKEDATE(2025, 366)
2026-01-01

Zero day number

MySQL 8.1
SELECT MAKEDATE(2025, 0);
MAKEDATE(2025, 0)
<NULL>

Details

In PostgreSQL, the similar function MAKE_DATE takes a year, month and day, not a day number. The closest replacement for MAKEDATE(year, n) there is MAKE_DATE(year, 1, 1) + (n - 1): n - 1 days are added to January 1.

See also