MySQL MAKEDATE() Function

Summary: in this tutorial, you will learn how to use the MySQL MAKEDATE() function to return a date based on a specified year and the day of the year.

Introduction to MySQL MAKEDATE() function

The MAKEDATE() function returns a date based on a specified year and day of the year. Here’s the MAKEDATE() function syntax:

MAKEDATE(year, dayofyear)Code language: SQL (Structured Query Language) (sql)

In this syntax:

  • year: This is the year for which you want to create a date.
  • dayofyear: This is the day of the year for which you want to create a date.

If year or dayofyear is NULL, the MAKEDATE() function returns NULL.

MySQL MAKEDATE() function example

The following example uses the MAKEDATE() function to calculate the date on the 60 days of 2023:

SELECT MAKEDATE(2023, 60);Code language: SQL (Structured Query Language) (sql)

Output:

+--------------------+
| MAKEDATE(2023, 60) |
+--------------------+
| 2023-03-01         |
+--------------------+
1 row in set (0.00 sec)Code language: SQL (Structured Query Language) (sql)

Summary

  • Use the MAKEDATE() function to make a date based on the year and day of the year.
Was this tutorial helpful?