Convert 5/3/2023 to 05/03/2023

Hello Community,
I have a situation where i have to read date from excel and update the value in SAP.

The date will be in string format in excel
Lets consider 3 situations
The date 5/12/2023
I want it to convert to 05/12/2023

The date 15/1/2023
I want it to convert to 15/01/2023

and the date 5/3/2023 to 05/03/2023.

Thank you.

Hi @hansen_Lobo

CDate(Input).ToString("dd/MM/yyyy")

Hi @hansen_Lobo

Try this:

DateTime.ParseExact(row("YourDateColumn").ToString, "d/M/yyyy", System.GLobalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Hope it helps!!

The input format i give and the format i get back are different:
image

@hansen_Lobo

How about this

DateTime.ParseExact(Input,"d/M/yyyy",System.Globalization.CultureInfo.CurrentCulture).ToString("dd/MM/yyyy")

what to do in this situation
The date 5/12/2023
I want it to convert to 05/12/2023

or

The date 15/1/2023
I want it to convert to 15/01/2023

@hansen_Lobo

1 Like

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