Change Date format from DD.MM.YYYY to MM/DD/YYYY

Hi All,

i am Unable to change the date from DD.MM.YYYY to MM/DD/YYYY.
I have used below code, Input is from excel so i have used row(“S4_Order_created_Date”):-

Cretated_Date= row(“S4_Order_Created_Date”).ToString.Trim
Created_Date=cDate(S4_Order_Created_Date).ToString(“MM/dd/yyyy”)

for this getting below error-
“message”: “Assign: Conversion from string "26.03.2020" to type ‘Date’ is not valid.”,

Could you Please help me with solution

Regards,
Keshav

@keshav Can you try this expression :
Created_Date ( String ) = DateTime.ParseExact(row(“S4_Order_Created_Date”).ToString.Trim,“dd.MM.yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

This will work if the date Format in the Excel is dd.MM.yyyy

1 Like

But I am not sure , Sometimes date format in excel like dd/mm/yyyy . So in that case will it work?

@keshav No, As far as I know we need to maintain a Fixed Input date format.