I have been using this expression DateTime.ParseExact ("20-Nov-23 00:00:00","dd-MMM-yy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture) .but it is throwing me a error like this
when assigning to dateVar of datetime type
If you using Read Range Workbook there is option in properties panel, Preserve Format option enable that and give the below syntax:
DateTime.ParseExact ("11/20/23", "MM/dd/yy", System.Globalization.CultureInfo.InvariantCulture)
Or else for your condition also please check below
DateTime.ParseExact("21-Nov-23 00:00:00","dd-MMM-yy HH:mm:ss" , System.Globalization.CultureInfo.InvariantCulture)
Please check the below image the output extracted perfectly
Regards
Please try using the statement below,
DateTime.ParseExact(str_Date, "MM/dd/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture)
Suggested by #autopilot ![]()