Forum Discussion
DATEDIF problem
- May 05, 2021
Let's take your first example: 29/03/4976 to 15/10/5346 (dd/mm/yyyy format).
DATEDIF calculates the number of days as follows:
- Move the maximum number of whole years forward from 29/03/4976 to end up before 15/10/5346. You arrive at 29/03/5346.
- Count the days between 29/03/5346 to 15/10/5346. This is 200.
Why did you get a different result? Because 4976 is a leap year. This causes the difference between 01/01/4976 and 29/03/4976 to be 1 day more. But you don't want to count from 01/01, but from 29/03. (Since 5346 is not a leap year, you don't count an extra day there)
So I would say that DATEDIF is correct here.
Let's take your first example: 29/03/4976 to 15/10/5346 (dd/mm/yyyy format).
DATEDIF calculates the number of days as follows:
- Move the maximum number of whole years forward from 29/03/4976 to end up before 15/10/5346. You arrive at 29/03/5346.
- Count the days between 29/03/5346 to 15/10/5346. This is 200.
Why did you get a different result? Because 4976 is a leap year. This causes the difference between 01/01/4976 and 29/03/4976 to be 1 day more. But you don't want to count from 01/01, but from 29/03. (Since 5346 is not a leap year, you don't count an extra day there)
So I would say that DATEDIF is correct here.