Q:

Why is the Date in Row being transformed automatically?

I'm using Miscrosoft Office Interop Excel to sort and manage a ".csv" file and create an excel file. 
When I copy one cell that contains a date for example : 

"04/05/2018 18:55"

I substring that into 

"04/05/2018"

and paste it into another cell, it transforms it into this weird number 

43195

Why is this happening? How can I prevent or modify this? I'm currently passing the info. like this:
String date = worksheet.Cells[1, 1].Value2.ToString();
worksheet.Cells[1, 2].Value2 = date; //this shows up as 43195

A:

It’s not being transformed really.  Excel actually stores all dates as a number representing the number of days since 1/0/1900 (really!).  What you are seeing in your cell is the raw numeric value representing the date.  If you open your result spreadsheet, highlight your column, right click and select formatting, and select “Date”, you’ll see it display the date you expect.
So you are going to want to do this in your code.  Assuming your date is in column “B” and your worksheet is “ws”:
ws.Range[“B:B”].NumberFormat = “mm/dd/yyyy”;

This assumes a US date format.

