Enigma?

User avatar
BobH
UraniumLounger
Posts: 9274
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Enigma?

Post by BobH »

No, not the famous code-breaking machine, but something I ran across.
In the attached file you will see 12 lines each with a begin and end date followed by the calculated number of days between those dates. The final row shows the sum of the number of days calculated and the calculated number of days from the first date in the first row to the last date in the last row.

The enigma is why numbers aren't the same. I've looked at this until I can no longer 'see' the problem.

:hairout: :scratch:
enigma.xlsx
You do not have the required permissions to view the files attached to this post.
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs

User avatar
HansV
Administrator
Posts: 78453
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Enigma?

Post by HansV »

Let's take row 2 as example. The start date in B2 is March 21 and the end date in C2 is April 20.
The formula in D2 =C2-B2 returns 30: it is 30 days from March 21 to April 20. But the period starting at March 21 and ending at April 20 has 31 days - it includes both the start date and the end date. To calculate the length of the period, you should use =C2=B2+1.
If you use that formula and fill down to D13, the sum in D14 changes to 365 - the number of days in a (non-leap) year.
The corresponding formula in E14 would be =C13-B2+1; this also returns 365.
Best wishes,
Hans

User avatar
BobH
UraniumLounger
Posts: 9274
Joined: 13 Feb 2010, 01:27
Location: Deep in the Heart of Texas

Re: Enigma?

Post by BobH »

Thanks, Hans!

I had developed a mental block from looking at it too long.
Bob's yer Uncle
(1/2)(1+√5)
Dell Intel Core i5 Laptop, 3570K,1.60 GHz, 8 GB RAM, Windows 11 64-bit, LibreOffice,and other bits and bobs