سؤال

I have an interval of 0012-11-03 (year-month-day) and would like to convert it to number of days:

12 * ~365 + Num of days From 01-01 To 11-03 = answer.

Leap year must be accounted for. (answer + 12/4 ??)

The closest thing I could come up with is using TO_DAYS() MySQL 5.1 but that function "does not take into account the days that were lost when the calendar was changed"

هل كانت مفيدة؟

المحلول

Are you really working with dates of 0012-11-03? I.e. the year 12 AD?

The calendar was not changed recently. They're referring to the days lost in the conversion from the Julian calendar to the Gregorian calendar in 1582 AD.

This should work:

SELECT TO_DAYS('2012-11-03') - TO_DAYS('2012-01-01');

Returns 307.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top