How to convert excel column (string) to date format

I have a problem: I need to get date in string format from excel file and convert it to date. How should I do this?

My goal is to fill date to calendar view in a website, where you can either type the date or click it from the calendar view.

Can anybody help with this? Thank you in advance <3

It depends on the format you need, but here’s how to do it if the date format for today is 2020-04-10:

If MyDatetime is the datetime you’ve pulled from Excel, then you can create a string variable and set it to MyDatetime.ToString("yyyy-MM-dd").

You can manage manipulate the way it’s being output using the ToString method.

Oh sorry I wrote it a bit wrong: MyDate in Excel is already in string format but I need to convert it to datetime format.

Our dates are in format 25.03.2019 format.

Thank you for your earlier reply!

Set your string to Date.ParseExact(MyStringDate, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture), where MyStringDate is the date you’ve pulled from Excel.


I tried this but all I got was this error: ‘String was not recognized as a valid DateTime’

What should I do?

And our ultimate goal is to add one day to the one that’s on our excel/ which is gotten from another website

Make sure the string that failed is formatted as you’ve specified. It must have exactly the same format.

Also, that post should have been DateTime.ParseExact(MyStringDate, "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture) based on the documentation below.