totn MariaDB Functions

MariaDB: MAKEDATE Function

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

Description

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

Syntax

The syntax for the MariaDB MAKEDATE function is:

MAKEDATE( year, day-of-year )

Parameters or Arguments

year
A 4-digit year used to create the date.
day-of-year
A 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 MariaDB:

  • MariaDB 10

Example

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

For example:

SELECT MAKEDATE(2014,1);
Result: '2014-01-01'

SELECT MAKEDATE(2014,15);
Result: '2014-01-15'

SELECT MAKEDATE(2014,176);
Result: '2014-06-25'

SELECT MAKEDATE(2014,365);
Result: '2014-12-31'

SELECT MAKEDATE(2014,366);        -- Not leap year in 2014
Result: '2015-01-01'

SELECT MAKEDATE(2016,366);        -- Leap year in 2016
Result: '2016-12-31'