Date Time format changed multiple times

If date format changed within minutes for that what we can use? Like convert to datetime(“dd,MM,yy”)

1 Like

Hi @Pardeep_Malik

Use an Assign activity to set your original date string and format:

originalDateString = "16,09,23 15:30:00"
originalFormat = {"dd,MM,yy HH:mm:ss","MM/dd/yyyy","M/d/yyyy"}

Use another Assign activity to parse the original date string into a DateTime object:

parsedDate = DateTime.ParseExact(originalDateString, originalFormat, System.Globalization.CultureInfo.InvariantCulture)

Finally, use a third Assign activity to convert the DateTime object to the new format:

newFormat = "dd,MM,yy"
newDateString = parsedDate.ToString

If your originalFormat variable keeps on changing then store all kind of time formats in an array and proceed with below process.

Hope it helps!!

@Pardeep_Malik

Is the datetime format changing frequently or the datetime vaue is changing?

If format is changing and if we have all the details about what all formats can come then use

Datetime.ParseExact(datestrvariable,{"MM/dd/yyyy","M/d/yyyy","MM/dd/yyyy HH:mm:ss"},System.Globalization.CultureInfo.InvariantCulture).ToString("dd,MM,yy")

This will give you the converted stirng type date in the required format…and if formats increase you can add more…as of now I added three formats in between flower brackets

Hope this helps

Cheers

Hi

We have a knowledge base on this
I would recommend to have a view on it for compete details

Hope this helps

Cheers @Pardeep_Malik

Hi,

Use DateTime.ParseExact function to convert the date from its current format to a DateTime object.

originalDate = DateTime.ParseExact(originalDate.ToString, “your_current_format”, System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yy”)