Convert String format of DateTime to Date format of DateTime

Hi Team,

We are doing a POC in capturing outage information from Dynatrace portal.

Outage details are in the format : Jul 30 17:26 (read as July 30th 5:26pm). While extracting this information using GetText activity, the output is in String format.

Need this string format of DateTime to be converted to date format of DateTime as :7/30/2020 17:26

Any help on the same is much appreciated.

Vinod Krishna

@Vinod_Krishna_C Check with this :

DateTime.ParseExact(yourString.Trim,“MMM dd HH:mm”,System.Globalization.CultureInfo.InvariantCulture)

Considering the Extracted String Date in this format :

Thanks for your response. Here’s what I’ve tried:

Created date_output variable of the format DateTime and assigned it as follows:

date_output = DateTime.ParseExact(yourString.Trim,“MMM dd HH:mm”,System.Globalization.CultureInfo.InvariantCulture)

and I got the following error:
Assign: String was not recognized as a valid DateTime.

Please help.

Note: yourString is a string variable whose value is " Jul 30 17:26 "

Vinod Krishna

@Vinod_Krishna_C Can you Hard code that value and check?

Tried hardcoding but no luck :frowning:

Any other suggestions/workaround?

Vinod Krishna

@Vinod_Krishna_C Actually Hard coding worked for me :sweat_smile: , Can you show me a Screenshot of how you have implemented it ?

My bad. I realized my typo. I had interchanged date and month :frowning:

Works like a charm. Thanks a ton :slight_smile:

1 Like

Also, how can we restrict from getting seconds in the output?

Program output is " 07/30/2020 17:26:00 " while we are expecting it to be only " 07/30/2020 17:26 "


@Vinod_Krishna_C You would have to Convert to String to restrict it, It won’t be available in DateTime format as far as I know it

If it is Acceptable, then try this :
DateTime.ParseExact(yourString.Trim,“MMM dd HH:mm”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy HH:mm”)

This is Additional.


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