Days Since 1 A.D. : Introduction « Date Time Functions « MySQL Tutorial






TO_DAYS(date) returns the number of days since the first day in the year 1 A.D. (there was no year 0).

The opposite effect is obtained by using FROM_DAYS(number).

mysql>
mysql> select TO_DAYS('2000-01-01') ;
+-----------------------+
| TO_DAYS('2000-01-01') |
+-----------------------+
|                730485 |
+-----------------------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> SELECT FROM_DAYS(1000000);
+--------------------+
| FROM_DAYS(1000000) |
+--------------------+
| 2737-11-28         |
+--------------------+
1 row in set (0.02 sec)

mysql>








14.1.Introduction
14.1.1.Date and Time Functions
14.1.2.Extraction Functions
14.1.3.Changing Date Values
14.1.4.Getting Day Information
14.1.5.Getting Names for Months and Days
14.1.6.Extracting Years, Quarters, Months, and Weeks
14.1.7.Current Date and Time
14.1.8.Days Since 1 A.D.
14.1.9.Seconds Since the Beginning of the Day