How to convert string to date format

I want to convert the “12/05/2018”, in USA format i.e MM/dd/yyy
Please help me
.

@Priya_Rajv
@ppr
@Rahul_Unnikrishnan
@ushu
@Palaniyappan

Variable type please

Hi @HeartCatcher ,

What about below

DateTime.ParseExact(“12/05/2018”,“dd/MM/yyyy”,system.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

Thanks,
Rajkumar

sure you can use a variable instead of the hard coded string from the prototype snippet

DateTime.ParseExact(YourStringVar,"dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).tostring("MM/dd/yyyy")

with the usage of ToString we do know that a string is returned

Hello @HeartCatcher

If you don’t want to go with expression, then you can use the Modify Date activity. You can select the format as per your need.

Thanks

how to split the date
10/18/2022 00:00:00
From above I need only 10/18/2022 the variable type is DateTime

how to split the date
10/18/2022 00:00:00
From above I need only 10/18/2022 the variable type is DateTime

we already did it above by using the toString method and reformat it to the requested format.

The dateTime internal structure we never touch

this string is another format so we can use
grafik

Datetime.ParseExact(YourStringVar,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).tostring("MM/dd/yyyy)

Try as above.

HI @HeartCatcher

How about this expression?

DateTime.ParseExact("10/18/2022 00:00:00",{"MM/dd/yyyy hh:mm:ss","MM/dd/yyyy HH:mm:ss","dd/MM/yyyy hh:mm:ss","dd/MM/yyyy","MM/dd/yyyy"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy")

Regards
Gokul

This expression will work for all the above formats @HeartCatcher

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