Convert Date time into specific format

Hi Team,

I Have to convert date time into specific format, Please help

IP: 13 Jul 2023 8:33:52 AM GMT -05.00
12 Jul 2023 8:33:52 AM GMT -05.00
11 Jul 2023 8:33:52 AM GMT -05.00

OP: 13 Jul 2023 8:33:52
12 Jul 2023 8:33:52
11 Jul 2023 8:33:52

Regards,
Manoj.

Hey @manojmanu.rpa

To remove GMT use below code
currentDateTime = currentDateTime.Replace(" GMT -05.00", "")

and to get in required format use below code
DateTime.ParseExact(currentDateTime, "dd MMM yyyy h:mm:ss tt", CultureInfo.InvariantCulture)

Hi @manojmanu.rpa

Try this:
ParsedDateTime = DateTime.ParseExact(InputDateTimeStr, "dd MMM yyyy h:mm:ss tt 'GMT' zzz", System.Globalization.CultureInfo.InvariantCulture).ToString("dd MMM yyyy h:mm:ss")

Hi @manojmanu.rpa

  1. Use this syntax in Assign activity
strinput(Datatype: Array(of String))= {"13 Jul 2023 8:33:52 AM GMT -05:00", "12 Jul 2023 8:33:52 AM GMT -05:00", "11 Jul 2023 8:33:52 AM GMT -05:00"}
  1. Run a For Each loop to iterate through above input
  2. Use Assign activity and give below syntax:
var_datetime(Datatype:System.Datetime)= DateTime.ParseExact(currentItem.ToString, "d MMM yyyy H:mm:ss tt 'GMT' zzz", System.Globalization.CultureInfo.InvariantCulture)
  1. Use assign activtiy and give below syntax:
output_date(Datatype: System.String)=var_datetime.ToString("dd MMM yyyy h:mm:ss ")
  1. Print it in Write Line.

Note: Shared the workflow for reference
Sequence3.xaml (8.5 KB)
Output:


As per the input you will be getting the above output.

Hope it helps!!

Thanks @supriya117 It works :clap:

1 Like

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