Conversion of Multiple Time formats into a single format

Hi all,

I want to convert the below date values into a format of DD/MM/YYYY.

13-Dec-16 --> 13/12/2016
19th August 2018 —> 19/08/2018
14-02-2014 ----> 14/02/2014
21-Dec-13 ---->21/12/2013

1 Like

Convert.ToDateTime( yourVariableName ).ToString(“dd/MM/yyyy”).tostring
cheers @saneeth_kandukuri

1 Like

is it working fine!?? @saneeth_kandukuri

When am using 19th August 2018, it giving error. please check it.

1 Like


You will have to use ParseExact function because you have a lot of different formats there…


It is throwing an error, please check at your end.


I had used

but it is throwing an error. could you please check it.

Try DateTime.ParseExact(YourDateString, PossibleDateFormatString[], IFormatProvider, DateTimeStyles)

Check the example here, it’s quite clear.

Maybe that format cant be parsed, i am not sure how…

if the input is in variable named strinput
then in ASSIGN activity mention like this which can take your date formats

stroutput = IF(System.Text.RegularExpressions.Regex.IsMatch(strinput.ToString,"[A-Za-z]+"),cdate(strinput.ToString.Replace(“th”,"").Replace(“rd”,"").Replace(“nd”,"")).ToString(“dd/MM/yyyy”),Datetime.ParseExact(strinput.ToString.Replace("-","").Replace("/",""),“ddMMyyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))

Cheers @saneeth_kandukuri

1 Like

Hi @Pradeep_Shiv,

You can use DateTime.ParseExact Method.

For your case:

DateTime.ParseExact(dateString, {"dd MM yyyy","dd - MM - yyyy"},System.Globalization.CultureInfo.InvariantCulture).tostring(“dd/MM/yyyy”)

Important Note:

Don’t forget to import System.Globalization in your XAML file

what is those curly brackets there?


Sorry for the late response.
If input is 21st August 2018 then the above code will not work.

1 Like

I missed that alone
Then the expression would be like this
stroutput = IF(System.Text.RegularExpressions.Regex.IsMatch(strinput.ToString,"[A-Za-z]+"),cdate(strinput.ToString.Replace(“th”,"").Replace(“rd”,"").Replace(“nd”,"").Replace(“st”,””)).ToString(“dd/MM/yyyy”),Datetime.ParseExact(strinput.ToString.Replace("-","").Replace("/",""),“ddMMyyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))

Cheers @saneeth_kandukuri

If you replace “st” with “”, then it will replace “st” in August, then it will not be a Valid date time.

1 Like

If the month is “Sept” it is throwing an error , please consider this issue too.

1 Like

That’s a good point
Fine so in that case did we try with this expression
stroutput = IF(System.Text.RegularExpressions.Regex.IsMatch(strinput.ToString,"[A-Za-z]+"),cdate(Split(strinput.ToString,” “)(0).ToString.Replace(“th”,"").Replace(“rd”,"").Replace(“nd”,"").Replace(“st”,””)+” “+Split(strinput.ToString,” “)(1).ToString.SubString(0,3)+” “+ Split(strinput.ToString,” “)(2).ToString).ToString(“dd/MM/yyyy”),Datetime.ParseExact(strinput.ToString.Replace("-","").Replace("/",""),“ddMMyyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”))

Cheers @saneeth_kandukuri

1 Like

you are really a hero man.
Inspired by you a lot .

1 Like

Have a great day