2007/3/5, Joe Smith <[EMAIL PROTECTED]>:
Johnny Andersson wrote: > ... If I do something like 2007-03-05 - 2007-03-03 the answer should > be 2 (days), right? But if I enter 2007-03-05 in A1, 2007-03-03 in > B1and =A1-B1 in C1, and then format C1 as DD, C1 shows 01, not 02 > which I think would be more appropriate. Dates are represented as an integer number of days after some starting date. If you subtract two such dates, you are simply subtracting two integers, so the result is an integer number of days between the dates: 39146-39144 = 2. What is does the result "2" now represent? > So why is 0 days = 1899-12-30? ...
Why not? Because it would be very convenient if it was 1899-12-31, or even more convenient if it was -0001-12-31 (but unfortunately, for some strange reason, there was no year 0 as they started with year 1, which I find incredibly stupid, on the other hand some people think that year 0 actually is the year -4 so that the last millennium actually started in 1996… This is probably quite another story, though). However, I thought about this for a while yesterday, and I found one explanation, which could be very wrong or maybe even right: Doesn't Excel start with 1899-12-31? And doesn't Excel have that leap year bug? If OpenOffice.org handles 1900 as a non leap year (as it should), then the start date have to be 1899-12-30 if recent dates are going to have the same numbers in Excel and OpenOffice.org Calc. If this is true, all dates, from 1900-03-01 until eternity, will have the same numbers in Excel and OpenOffice.org Calc. Examples: 1900-01-01: OpenOffice.org: 2 Excel: 1 1900-02-28: OpenOffice.org: 60 Excel: 59 1900-02-29: OpenOffice.org: Doesn't exist Excel: 60 1900-03-01: OpenOffice.org: 61 Excel: 61 2007-03-06 OpenOffice.org: 39147 Excel: 39147 This is just my own theory, can it possibly be true?
Or just Document_date - Birth_date + 1, formatted as YY. ... No, for the same reason that "2" formatted as "DD" gives you the wrong answer.
That is what the "+ 1" was for, to prevent that from happening. Of course (back to the original question), if you're entering the birth
date and the document date by hand already, why not just enter the years rather than the exact date. No more problem, just Doc_year - Birth year. <Joe
Just don't forget about leap years. One year in average is approximately 365.2425 days: When a year divided by 100 is an integer, such as 1800, 1900, 2000 etc, it's only a leap year if the year divided by 400 also is an integer, so 1900 was not a leap year, 2000 and 1600 was. So in 400 years we have (100 / 4 - 1) + (100 / 4 - 1) + (100 / 4 - 1) + 100 / 4 = 100 / 4 - 3 = 97 leap years -> One year = (400 · 365 + 97) / 400 = 365.2425 days in average. Not that it matters THAT much…
