문제

Which is more correct?

SQL:

select datediff(HOUR, '2013-01-01 00:00:00 AM','2013-12-31 11:59:59 PM') = 8759

Google: https://www.google.com/search?q=hours+ina+year&oq=hours+in+a+year = 8765.81

도움이 되었습니까?

해결책

Here Google calculator is using the Tropical year, which is the time the earth takes to orbit the sun. If you disregard our calendar, there are 365.24 24-hour days in a year, which is useful if you want “year” to have a constant value you can use as a unit.

You probably don’t want to disregard our calendar, so there are 365 or 366 days in a year.

다른 팁

They are showing you different things.

Google is showing you the astronomical year - time it takes Earth to turn around the Sun once (matches the number from wiki).

SQL is showing you the right number, apart from the fact that you have a rounding error (because you miss one last minute). It should be 8760 which is 24*365.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top