MySQL MAKEDATE() Function

In MySQL, the MAKEDATE() function creates and returns a date based on the year and the number of days in the year.

MAKEDATE() Syntax

Here is the syntax of MySQL MAKEDATE() function:

MAKEDATE(year, day_of_year)

Parameters

year
Required. 4 digits year.
day_of_year
Required. The day of the year and it should be greater than 0.

Return value

The MySQL MAKEDATE() function creates and returns a date based on the year and the number of days in the year.

If day_of_year is not greater than 0, the MAKEDATE() function will return NULL.

MAKEDATE() Examples

Here are some examples of the MAKEDATE() function.

SELECT
    MAKEDATE(2022, 1),
    MAKEDATE(2022, 31),
    MAKEDATE(2022, 32),
    MAKEDATE(2022, 0)\G
 MAKEDATE(2022, 1): 2022-01-01
MAKEDATE(2022, 31): 2022-01-31
MAKEDATE(2022, 32): 2022-02-01
 MAKEDATE(2022, 0): NULL