Link to home
Create AccountLog in
Avatar of rwheeler23
rwheeler23Flag for United States of America

asked on

C# read datews in Excel and wtite them to SQL as datetime.

I am reading an Excel spreadsheet and one of the columns is a date column.

Sending the date to the string using MessageBox.Show(xlRange.Cells[i, j].Value2.ToString()) yields 10/23/2023. I need to convert this to a datetime value that I can then pass down to a SQL stored procedure.

I have attached code from another application that converts the Excel date to a string. 

What would I need to do to this code to get it to return a datetime value?


Date2Field.txt


ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer