Name

MAKEDATE( )

Synopsis

MAKEDATE(year, day)

This function converts a given day of the year of a given year to a date in yyyy-mm-dd format. The day given can be from 1 to 365 (366 for leap years). It returns NULL if a value less is than 1 or greater than the maximum number of days allowed. This function is available as of Version 4.1.1 of MySQL.

SELECT MAKEDATE(2005, 1) AS 'First Day',
       MAKEDATE(2005, 365) AS 'Last Day';
+------------+------------+
| First Day  | Last Day   |
+------------+------------+
| 2005-01-01 | 2005-12-31 |
+------------+------------+

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.