MAKEDATE
MAKEDATE is an SQL function that generates a date value based on a given year and day of the year. It returns a date in 'YYYY-MM-DD' format.
MAKEDATE(year, dayofyear)
- year: This refers to the four-digit year part of a date value in MySQL. Its range is from 1000 to 9999.
- dayofyear: This corresponds to the day of the year, ranging from 1 to 366. It calculates the combined date after taking the specified year and adding the number of days to it.
Example
Output
Explanation
In the given example, the MAKEDATE
function creates a date from the year (2021) and day-of-year (365) values provided to it. Thus, the output is a date (2021-12-31) which corresponds to the 365th day of year 2021.