Convert different(multiple) types of date into the one fix date format

Hi Team,

I want to convert different types of Dates into the one-fix date format.

Note:- I don’t know the input date format because the user enters the date to asset into the orchestrator, so the input date format is not fixed.

Ex.:-

input:-
“23-10-2023”
“23/10/2023”
“23 Oct 23”

output is:-
23 October 2023
23 October 2023
23 October 2023

Thanks
Minal P

Hi @minal.patil

Can you try with this expression

DateTime.ParseExact(YourInput.ToString,{"dd-MM-yyyy","dd/MM/yyyy","dd MMM yy"}, System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("dd MMMM yyyy")

Regards
Gokul

image

I don’t know the date format. I am just giving examples and not fixing 3 types of input formats. There are one/many.

Hi,

Can you try the following expression?

CDate(System.Text.RegularExpressions.Regex.Replace(currentItem,"(\d+)\W+(\w+)\W+(\d+)","$2/$1/$3").Trim).ToString("dd MMMM yyyy")

Sequence.xaml (6.5 KB)

Regards,

2 Likes

One way to alleviate this would be to instruct users. Create a guide and name the asset to include the format, eg. assetName_dd-MM-yyyy or such. I think it’s not possible to parse all different formats, since there’s a possibility to mix days and months - eg. 10/1/2023, 10 can be the day number of month number).

Hi

Its working but 23-10-2023 date is not fixed its change dynamically as per requirement.
when I am change date like 25-10-2023 it will give output :- 23-10-2023

You need to add the date fromat as per the input in the expression above @minal.patil