简体   繁体   中英

Days between two dates in excel

I'm trying to calculate the number of days between two dates in Excel and am running into a weird issue.

I know that I should be able to just subtract the dates, but it's not behaving.

Right now I have 3 dates, using a custom format of yyyy-mm-dd:

2007-06-08, 2007-06-20, 2008-06-20, (A1, B1, C1)

I then try to calculate the difference between these.

=C1-A1 ("2008-06-20"-"2007-06-08") returns 378, formatted as a general cell, as expected.

=C1-B1 (2008-06-20"-"2007-06-20") returns "1900-12-31" formatted with the custom yyyy-mm-dd format.

I'm confused. As far as I can tell both of these calculations take in equivalent data, formatted the same, but produce very different results.

Anyone have any insight?

As highlighted by Ron Rosenfeld above, the issue was with cell formatting. Excel was formatting the two columns differently. When formatted as general the results were both as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM