MySQL FROM_DAYS() Function

In MySQL, the FROM_DAYS() function converts the specified number of days to a date and returns it. It is the opposite of the TO_DAYS() function.

FROM_DAYS() Syntax

Here is the syntax of MySQL FROM_DAYS() function:

FROM_DAYS(days)

Parameters

days
Required. An integer value representing the number of days sine year 0.

Return value

The MySQL FROM_DAYS() function returns a date represented by the specified number of days.

If the argument is NULL, the DAYOFYEAR() function will return NULL.

FROM_DAYS() Examples

Here are some examples of the FROM_DAYS() function.

SELECT
    FROM_DAYS(738579),
    FROM_DAYS(738580);
+-------------------+-------------------+
| FROM_DAYS(738579) | FROM_DAYS(738580) |
+-------------------+-------------------+
| 2022-02-28        | 2022-03-01        |
+-------------------+-------------------+

The FROM_DAYS() function is the opposite of the TO_DAYS() function.

SELECT
    TO_DAYS('2022-02-28'),
    FROM_DAYS(TO_DAYS('2022-02-28')),
    FROM_DAYS(738579);
+-----------------------+----------------------------------+-------------------+
| TO_DAYS('2022-02-28') | FROM_DAYS(TO_DAYS('2022-02-28')) | FROM_DAYS(738579) |
+-----------------------+----------------------------------+-------------------+
|                738579 | 2022-02-28                       | 2022-02-28        |
+-----------------------+----------------------------------+-------------------+