Re: excel dates
Re: excel dates
- Subject: Re: excel dates
- From: Theodore Petrosky <email@hidden>
- Date: Mon, 28 Nov 2016 17:08:57 -0500
Why does excel behave so badly. well the original website I found said that excel calculated dates fro 01/01/1900 but that was incorrect. it is really 01/00/1900, but there is more:
Actually, this number is one greater than the actual number of days. This is because Excel behaves as if the date 1900-Feb-29 existed. It did not. The year 1900 was not a leap year (the year 2000 is a leap year). In Excel, the day after 1900-Feb-28 is 1900-Feb-29. In reality, the day after 1900-Feb-28 was 1900-Mar-1 . This is not a "bug". Indeed, it is by design. Excel works this way because it was truly a bug in Lotus 123. When Excel was introduced, 123 has nearly the entire market for spreadsheet software. Microsoft decided to continue Lotus' bug, in order to fully compatible. Users who switched from 123 to Excel would not have to make any changes to their data. As long as all your dates later than 1900-Mar-1, this should be of no concern.
My head hurts. On Nov 28, 2016, at 1:17 PM, Leigh Kivenko < email@hidden> wrote:
I think the century rule is overridden if it is also divisible by 400. So that explains 2000 and 1 of your days. The other day might just be an offset? Leigh Kivenko | VP, Technology PortfolioAid t. 416-479-0523 | e. email@hidden This e-mail may be privileged and confidential. If you received this e-mail in error, please do not use, copy or distribute it, but advise me immediately (by return e-mail or otherwise), and delete the e-mail. So excel stores and expects to find date as an integer. The number of days since 01-01-1900. I am trying to write out to excel and I have these dates. So is created a method that calculates the number of days from 01-01-1900. My problem is that I am two days off, so I adjusted the jan01 date two days. Does anyone know why it is two days off? the only thing I can think of is that it is calculating the leap years incorrectly. every four years except century years, and there are two century years here (1900 and 2000), SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); date = format.parse ( "1899-12-30" ); } catch (ParseException e) { // TODO Auto-generated catch block NSTimestamp jan011900 = new NSTimestamp(date); System.out.println(jan011900); long diff = eventDate().getTime() - jan011900.getTime(); // diff is in milliseconds long roundingOffset = ( diff >= 0 ) ? 12 : -12; // if diff is positive, offset up, if negative, offset down // next, convert diff to hours, offset by .5 days to round the end result, divide by 24 and truncate. long days = ( ( diff / ( 1000 * 60 * 60 ) ) + roundingOffset ) / 24;
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >excel dates (From: Theodore Petrosky <email@hidden>) |