How to convert DateTime to Excel Date?

D

Dorell

Hi All

I’m trying to insert dates directly into an Excel file but Excel is not
recognising the values as dates. At the moment I’m calculating the total
number of days between “30/12/1899 00:00:00†and the specified dates using
the TimeSpan class but the result is never exactly the same as an Excel date,
there’s always a slight, slight difference at the end of the decimal value.

Is there a standard way in C# to convert a DateTime (“29/03/2009 20:53:26â€)
to an Excel date (39901.870439814818)?

Thanks
Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top