My program creates an output in Excel.
Some of the dates seem to be getting misinterpreted:
Just replace (to string) with (formated value)
The issue here is that you are writing everything to Excel as a string, and Excel will store it as such. On editing and pressing Enter, Excel will re-interpret the cell contents and may then store it differently.
When you call ToString()
on a DateTime
, the default formatting is in the form DD/MM/YY HH:mm:ss, which is exactly what you are seeing in the resultant file.
Dates in Excel are stored as numbers representing the number of days that have elapsed since 1900. To get this number, you can call the ToOADate()
method.
See http://msdn.microsoft.com/en-gb/library/system.datetime.tooadate.aspx
With the data set as a double
and an appropriate format string, you should get the result you're hoping for!