Date convert str to datetime

str_ETADate: 10/13/2022 00:00:00

Need this date format in date_ETADate

I have written date_ETADate = DateTime.ParseExact(str_ETADate,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)
and in catch MM/dd/yyyy also use
but receive output is date_ETADate = [01/01/0001 00:00:00]

Require output is 10/13/2022

grafik

you swapped day, month part. So it is failling

grafik

I have use try catch and in try catch MM/dd/yyyy also use but still fails

waiting for solution if possible
Thank you

as you see that the screenshots are done within immediate panel (UiPath Debugging) we do have the confirmation that code is working

Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

so you can use also these panels and check / inspect the values. Maybe you also have to include the time portion into the format. But as showcased above:

MM/dd/yyyy HH:mm:ss can be handled with CDate

1 Like

@satish.rathi59

This is what you need to use

DateTime.ParseExact(str_ETADate,”MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)

As you have time also yoi have to include in the format…

Then use .ToString(“MM/dd/yyyy") so that you het the required format in string…

By default the datetime variable is stored as date and time

Hope this helps

Cheers

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