سؤال

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