Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I'm generating an Excel file using Microsoft.Office.Interop.Excel dll. I have an issue when I set the NumberFormat as "MM/dd/yyyy". When the date is less than 1900 it throws an exception.

I could understand that the DateTime format allows the column to hold date till 1900. Now how shall I change the format to hold date less than 1900?

Please help.

Thanks,
Srikanth
Posted
Updated 15-Dec-10 0:07am
v2
Comments
fjdiewornncalwe 15-Dec-10 14:34pm    
Why would you need the spreadsheet to hold dates earlier than 1900? If it is a static field, you could also perform a transformation and store the value as a string value column in the format you want instead of as a number format.

Maybe Excel doesn't support dates earlier than 1900... have you googled it?

EDIT ==============

I googled it, and found out that the earliest possible date Excel will accept is 01/01/1900. You're out of luck, Sparky. Here's the link I found the info at:

http://www.ozgrid.com/Excel/free-training/excel-lesson-13-basic.htm[^]

Scroll down to the section labeled "Excel Dates and Times".


 
Share this answer
 
v3
You probably should not use a date before 1900 anyway and Excel mistakenly thinks 1900 is a leap year, so the date serial is off that year anyway.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900