Given a date, returns a number of days starting from year 0
select TO_DAYS(now()) as days
select TO_DAYS(now()) as days
As you can see, from From AD 0 to November 29, 2021, there are a total of 739,488 days. Remember this number
select TO_DAYS('21-11-29') as days
. You can see that the number of days is the same, and the year is only written after Two digits will be automatically converted to 4 digits
The rules in MySQL "Date and Time Type" convert the two-digit year value in the date to four digits
For dates before 1582 (or perhaps the next year in other regions), the results of this function are unreliable
The above is the detailed content of How to use mysql date function TO_DAYS() function. For more information, please follow other related articles on the PHP Chinese website!