Change DateTime Format from Various Inputs

Hello everyone

I’d like to change the datetime format of a given string to MM/dd/yyyy. However, the input string can have various formats (yyyy-dd-mm, MM/dd/yy, etc.) Is there an easy way to accomplish this, not knowing the format of the input string?

Hi @sidb

You can try with this expression

DateTime.ParseExact(YourString,{"yyyy-dd-MM","MM/dd/yy","MM/dd-yyyy"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy")

Regards
Gokul

3 Likes

You can update Date format here

In the expression @sidb

Output

image

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.