MySQL MAKEDATE function is one of the MySQL Date Functions, which returns or gets the date from year and day of year given by us. The syntax of the Makedate Function in MySQL is as shown below:
MySQL Makedate function Example
These examples help you understand the use of this MySQL Make date function. 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 MySQL Makedate function. In this Date Function example, we are trying to return 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.
SELECT MAKEDATE(2017, 365), MAKEDATE(2017, 366);
SELECT MAKEDATE(2017, 765), MAKEDATE(2017, 1366);
MySQL MAKEDATE Function Example 2
The following MySQL 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 functions inside this MAKEDATE. This might helps you to understand how we can use other date functions inside the MAKEDATE function.
Within the Next statement, we used 0 as a day of number. That’s why it has returned NULL.