Forum Discussion

vt1701's avatar
vt1701
Copper Contributor
May 05, 2021
Solved

DATEDIF problem

Hello,   I'm working at an application (internal use) requiring compatibility with the serial numbers generated by Excel for date values. During the testing phase, I've noticed strange issues (fail...
  • HansVogelaar's avatar
    May 05, 2021

    vt1701 

    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:

    1. 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.
    2. 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.

Resources