i am trying to convert to date:
date = Date.ParseExact(“1.02.2022”,“dd.MM.yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo)
But i get error,
Please try this
Date.ParseExact(“1.02.2022”,“d.MM.yyyy”, System.Globalization.CultureInfo.InvariantCulture)
the format that you provide should exactly match with the input date you provide
cheers
You have passed 1 and in format dd.
Pass 01 in first argument.
Or change both as same format.
Try with this it will work
Date.ParseExact(“1.02.2022”,“d.MM.yyyy”, System.Globalization.CultureInfo.InvariantCulture)
Thanks
Varun
this works.
Although it produces the US format, any chance of it staying in format given? and remove the extra 00:00:00?
you can use .ToString(“MM/dd/yyyy”) to convert to any format you need.
You can as well use .Date to get only the date
cheers