question

JaimeStuardo-5606 avatar image
0 Votes"
JaimeStuardo-5606 asked emizhang-msft commented

Excel internal date format doubt.

Hello,

I developed an application that has a task of reading an Excel file. Among the read data are dates.

When a cell in Excel has a date format it is actually returned as a number, for example, if I have a cell with the date "10th may 2021", when reading that sheet, number 44,326 is actually returned.

By reading some pages in Internet, they say that number is the number of days since 1st january 1900. However, if I add 44,326 days to 1st january 1900, the resulting date is 12th may 2021, which is 2 days later the right date.

To solve the problem, I am subtracting 2 days to the result, but this seems to be a trick instead of doing the right thing.

Can anybody explain me why I should subtract 2 days to get the right result? According to docs, the right number of days returned by Excel should be 44,324.

Thanks
Jaime

office-excel-itpro
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

emizhang-msft avatar image
0 Votes"
emizhang-msft answered emizhang-msft commented

Hi anonymous usertuardo-5606,
Refer to this support article:
https://support.microsoft.com/en-us/office/date-systems-in-excel-e7fe7167-48a9-4b96-bb53-5612a800b487

Check if you enable the 1904 date system, you can go to File- Options- Advanced- Under When calculating this workbook, uncheck Use 1904 date system option:

95477-373.png

Just checking in to see if the information was helpful. Please let us know if you would like further assistance.


If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.





373.png (36.5 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello, thanks for answering.

It is already unchecked in my case, however, this software will be used not only by me, so it is important not to depend on some kind of configuration. I understand that setting is unchecked by default.

And I as told, the difference is just 2 days, and not 4 years.

Regards
Jaime

0 Votes 0 ·

Did you check if the system date correct?

0 Votes 0 ·