Convert "1.02.2023" to date string?

i am trying to convert to date:
date = Date.ParseExact(“1.02.2022”,“dd.MM.yyyy”, System.Globalization.DateTimeFormatInfo.InvariantInfo)
But i get error,

@Rowley101

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.

@Rowley101

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?
image

@Rowley101

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