Summary: in this tutorial, you will learn how to use the MySQL FROM_DAYS()
function to convert a numeric day count into a date.
Introduction to MySQL FROM_DAYS() function
The FROM_DAYS()
function returns a numeric day count into a date.
Here’s the syntax for the FROM_DAYS()
function:
FROM_DAYS(days)
Code language: SQL (Structured Query Language) (sql)
In this syntax:
days
: This parameter is the number of days since'0000-00-00'
that you want to convert into a date.
In practice, you use the function when working with date data stored as the number of days since the date '0000-00-00'
.
MySQL FROM_DAYS() function example
The following example uses the FROM_DAYS()
function to convert a numeric day count into a date:
SELECT
FROM_DAYS(737989) AS converted_date;
Code language: SQL (Structured Query Language) (sql)
Output:
+----------------+
| converted_date |
+----------------+
| 2020-07-18 |
+----------------+
1 row in set (0.00 sec)
Code language: plaintext (plaintext)
Summary
- Use the MySQL
FROM_DAYS()
function to convert a numeric day count into a date.
Was this tutorial helpful?