This project has moved and is read-only. For the latest updates, please go here.

Can't enter DateTime greater than 24 hours

Oct 27, 2011 at 1:06 PM

I want to enter date like below :


DateTime date = new DateTime(new TimeSpan(1, 0, 49, 11).Ticks); 
worksheet.Cells[1, 1].Value = date;
worksheet.Cells[1, 1].Style.Numberformat.Format = "[h]:mm:ss";

In debugger (at runtime) the date looks ok. But when I open the file Excel makes it 00:00:00. It seems that I cannot enter date which is higher than 24 hours, for example when I enter values "0, 1, 49, 11" excel shows correct time. Is this a MS Excel bug?

Oct 28, 2011 at 3:29 PM

I'm not sure, If you can do it in Excel, unzip the document and look at the worksheet.xml

Nov 16, 2011 at 9:15 AM

I've worked around this by formatting the date as text and giving the above format. Excel is capable to compare 2 dates formatted like this and the return value is also a date.