문제

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