Page 1 of 1

Interpretation of dates by Excel and Dyalog

Posted: Fri Dec 02, 2011 5:59 pm
by Tranber44
Hello,

Having noticed that Dyalog APL and Excel did not interpret in the same way dates

Dyalog :
+2 ⎕NQ '.' 263 40878
2011 12 2 4

Excel :
40878 -> 01/12/2011 (format Date DD/MM/YY)

I made a small search and I noticed the following difference

Dyalog :
+2 ⎕NQ '.' 263 59
1900 2 28 2
+2 ⎕NQ '.' 263 60
1900 3 1 3

Excel :
59 -> 28/02/00
60 -> 29/02/00

Who is right? Turn of the century, Dyalog would be right? But...

Thanks

Re: Interpretation of dates by Excel and Dyalog

Posted: Fri Dec 02, 2011 8:39 pm
by AndyS|Dyalog
Dyalog is correct.

There is a note in the documentation about this:

"An IDN is an integer that represents a date as the number of days starting at Jan 1st 1900, i.e. Jan 01 1900 is IDN 1.

Note that IDNs calculated by Dyalog APL do not precisely match IDNs calculated by Microsoft Excel which incorrectly assumes that 1900 was a Leap Year."

1-2-3 got it wrong in the first place, and Excel went the same way for compatibility reasons. Excel does have the option to start counting dates from Jan 02 1904 - so you may need to worry about that possibility too in your code :-(

Re: Interpretation of dates by Excel and Dyalog

Posted: Sat Dec 03, 2011 10:10 am
by DanB|Dyalog
This is known oddity with Excel which apparently tried to stay compatible with Lotus 1-2-3 on which it is based.
In these programs 1900 is considered a leap year (which it isn't).
Dyalog does not follow this "convention" and counts the days since 1899-12-31.
Therefore +2 ⎕NQ '.' 263 1 is 1900-1-1 just like Excel but is different starting at +2 ⎕NQ '.' 263 60.
Hope this helps.