MySQL MAKEDATE function is a Date Function, which is used to return or get date from year and day of year given by us.
In this article, we will show you, How to use this MySQL Make Date function to get date with an example.
MySQL Makedate Syntax
The basic syntax of the Makedate() Function in MySQL is as shown below:
MySQL Makedate function Example
These examples helps you understand the use of this MySQL Makedate function. Here, we are trying to return or get date based on the year and day of year.
SELECT MAKEDATE(2017, 25);
SELECT MAKEDATE(2017, 32);
SELECT MAKEDATE(2017, 185);
Let us see another example of MySQL Makedate function. Here, we are trying to return date from day of number greater than 366
When you specify the day of number more than 365, 366 (Leap) then it will increment the year.
SELECT MAKEDATE(2017, 365), MAKEDATE(2017, 366);
SELECT MAKEDATE(2017, 765), MAKEDATE(2017, 1366);
MySQL MAKEDATE Function Example 2
The following queries show you, what happens when we try to return the date from 0 year or 0 day of 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 MAKEDATE function.
Within the Next statement, we used 0 as day of number. That’s why it has retuned NULL.
Thank You for Visiting Our Blog