Convert string ex: "March 2, 2020" into DateTime variable with same format

Hello everyone, i can’t convert string ex: “March 2, 2020” into DateTime variable with same format

i have try
tempDate = Convert.toDatetime(Datetime.parseexact(tempDateString, “MMMM d, yyyy”, Globalization.CultureInfo.InvariantCulture).ToString(“MMMM d, yyyy”))

in Assign Activity

but the output is
03/16/2020 00:00:100:

Please, help me


This looks like it works. Compare this workflow to your own to see what might be going wrong. (17,9 Ko)

The output still same @Anthony_Humphries
Screen Shot 2020-03-19 at 20.50.08
“03/16/2020 00:00:00” (ignore the other string)

1 Like

This is what i do
Screen Shot 2020-03-19 at 20.49.48

Screen Shot 2020-03-19 at 20.49.36

Can you take a screenshot of the value of tempDateString after it’s assigned?

I also ‘write line’ for you, same tempDateString with ‘+’ to make sure there is no additional space

I meant the local variables (highlighted in the screenshot below). That way I can see what the value of the original string was as it was passed in, and what it became after conversion. You’ll also see that I’ve stopped the process just after the conversion takes place.

Owhh soryy :sweat_smile:

It looks like your input string is set to “March 16, 2020”, which is why you’re getting 03/16/2020 instead. If you need to get the date 14 days ago, you can append .AddDays(-14) to your datetime conversion to go back 14 days.

1 Like

No, that’s not what I wanted

I want to convert string var type “MMMM d, yyyy” into DateTime var type with same format

The datetime itself will not hold the format, as the formatting is applicable only to strings. However, if you need to manipulate this date in some way, you can convert it back to its original format like this:

MyDateTimeStr = MyDateTime.ToString("MMMM d, yyyy")

Woahh, I just know that from you

Big thanks @Anthony_Humphries

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