totn MySQL Functions

MySQL: MAKEDATE Function

This MySQL tutorial explains how to use the MySQL MAKEDATE function with syntax and examples.

Description

The MySQL MAKEDATE function returns the date for a certain year and day-of-year value.

Syntax

The syntax for the MySQL MAKEDATE function is:

MAKEDATE( year, day-of-year )

Parameters or Arguments

year
The 4-digit year used to create the date.
day-of-year
The day of the year (greater than 0) used to create the date.

Note

  • If day-of-year is less than 1, the MAKEDATE function will return NULL.

Applies To

The MAKEDATE function can be used in the following versions of MySQL:

  • MySQL 5.7, MySQL 5.6, MySQL 5.5, MySQL 5.1, MySQL 5.0, MySQL 4.1.1

Example

Let's look at some MySQL MAKEDATE function examples and explore how to use the MAKEDATE function in MySQL.

For example:

mysql> SELECT MAKEDATE(2014,1);
        -> '2014-01-01'

mysql> SELECT MAKEDATE(2014,31);
        -> '2014-01-31'

mysql> SELECT MAKEDATE(2014,32);
        -> '2014-02-01'

mysql> SELECT MAKEDATE(2014,200);
        -> '2014-07-19'

mysql> SELECT MAKEDATE(2014,365);
        -> '2014-12-31'

mysql> SELECT MAKEDATE(2014,366);
        -> '2015-01-01'