MySQL MAKEDATE is one of the Date Functions, which returns or gets the date from year and day of year given by us. The syntax of the MySQL Makedate Function is as shown below:
MySQL Makedate function Example
These examples help you completely understand the use of this method. Here, we are trying to return or get a date based on the year and day of the year.
SELECT MAKEDATE(2017, 25);
SELECT MAKEDATE(2017, 32);
SELECT MAKEDATE(2017, 185);
Let us see another example of the MySQL Makedate function. In this method example, we are trying to return the date from the day of a number greater than 366. When you specify the day of a number more than 365, 366 (Leap), then it increments the year by the value.
SELECT MAKEDATE(2017, 365), MAKEDATE(2017, 366);
SELECT MAKEDATE(2017, 765), MAKEDATE(2017, 1366);
The following MySQL MAKEDATE Function queries show you what happens when we try to return the date from 0 years or 0 days of the year.
SELECT MAKEDATE(YEAR(NOW()), DAYOFYEAR(NOW()));
SELECT MAKEDATE(2019, 0);
SELECT MAKEDATE(0000, 30);
From the above screenshot, First, we used the YEAR, DAYOFYEAR, and NOW methods inside this MAKEDATE method. This might helps you to understand how we can use other date methods inside it Within the Next MySQL statement, we used 0 as a day of number. That’s why it has returned NULL.