The FROM_DAYS() function is used to convert a numeric day value (representing the number of days since '0000-01-01') into a date value. This function is useful for working with numeric representations of dates.
Definition and Usage
- The
FROM_DAYS()function returns a date corresponding to a given numeric representation of a day. - This numeric value represents the number of days since the start of the Gregorian calendar ('0000-01-01').
Syntax
FROM_DAYS(number)
- number: Required. A numeric value representing the number of days since '0000-01-01'.
Examples
Example 1: Return a date from a numeric day value
SELECT FROM_DAYS(685467);
Output:
2017-06-15
This example converts the numeric value 685467 into the corresponding date 2017-06-15.
Example 2: Return a date from a different numeric day value
SELECT FROM_DAYS(780500);
Output:
2023-11-15
This example converts the numeric value 780500 into the corresponding date 2023-11-15.
Technical Details
- Works in MySQL versions: From MySQL 4.0.
- Note: The number used with
FROM_DAYS()represents the number of days from the start of the Gregorian calendar. It's the inverse of theTO_DAYS()function, which converts a date into a numeric day value.
Related Functions
TO_DAYS(): Converts a date to a numeric day value, which is the opposite of theFROM_DAYS()function.