Name

FROM_DAYS( )

Synopsis

FROM_DAYS(value)

This function returns the date based on the number of days given, which are from the beginning of the currently used standard calendar. Problems occur for dates before 1582 when the Gregorian calendar became the standard. The opposite of this is TO_DAYS().

SELECT FROM_DAYS((365.25*2005))
          AS 'Start of 2005?';
+----------------+
| Start of 2005? |
+----------------+
| 2005-01-15     |
+----------------+

Assuming that there are 365.25 days in a year on average (allowing for the leap year), you would think that multiplying that factor by 2005 would give a result of January 1, 2005, but it doesn’t because of the calendar changes centuries ago. This function is useful for comparing dates, not for determining static information on one date.

Get MySQL in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.