MariaDB FROM_DAYS() Function

In MariaDB, FROM_DAYS() is a built-in function that converts the specified number of days from standard time (0000-00-00) to a date and returns it.

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

MariaDB FROM_DAYS() Syntax

This is the syntax of the MariaDB FROM_DAYS() function:

FROM_DAYS(days)

Parameters

days

Required. An integer value representing the number of days from standard time (0000-00-00).

If you provide no parameters or the wrong number of parameters, MariaDB will report an error: ERROR 1582 (42000): Incorrect parameter count in the call to native function 'FROM_DAYS'.

Return value

The MariaDB FROM_DAYS() function returns the date converted to the specified number of days from standard time (0000-00-00).

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

MariaDB FROM_DAYS() Examples

This statement shows the basic usage of the MariaDB FROM_DAYS() function:

SELECT
    FROM_DAYS(738579),
    FROM_DAYS(738580);

Output:

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

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

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

Output:

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

Conclusion

In MariaDB, FROM_DAYS() is a built-in function that converts the specified number of days from standard time (0000-00-00) to a date and returns it.