.NET Questions (CLOSED)

Questions and Answers on any aspect of .NET. Now closed.

This discussion group is now closed.

Have a question about .NET development? Try stackoverflow.com, a worldwide community of great developers asking and answering questions 24 hours a day.

The archives of .NET Questions contain years of Q&A. Even older .NET Questions are still online, too.

Date Rant

The topic is reading dates from Excel into VS/C#.

Excel help says: "Microsoft Excel stores dates as sequential numbers which are called serial values. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,448 days after January 1, 1900. Excel stores times as decimal fractions because time is considered a portion of a day." There is a problem right there because the day that is 39,448 days after day 1 is day 39,449.

A cell on a spread sheet has date 1/1/2008. When I read it in C# via Interop, I get a double with value v = 39,488. Then:

DateTime base_date  = new DateTime(1899,12,31) ;
DateTime final_date = base_date.AddDays(Convert.ToInt32(v)) ;

The value of final_date is 1/2/2008.

Nutmeg programmer
Tuesday, January 15, 2008

Tuesday, January 15, 2008
I'd read that before, but forgotten. Thanks.

It doesn't excuse the explanation in Excel Help, though.
Nutmeg programmer
Tuesday, January 15, 2008
I think DateTime.FromOADate might give the result you want.
Monday, January 21, 2008

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Powered by FogBugz