Convert date 12-01-2024 to date format "2024-01-12"

I have extracted date as

startdate = 12-01-2024 (its a string value)

I want to convert to date variable in format (2024-01-12)

can someone help again.

Hi @Ellen

Try this:

startdate = "12-01-2024" 
Output= Datetime.ParseExact(startdate.ToString, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")

Output DataType: System.String

Regards

Hi @Ellen

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

Regards,

please let us know if 12 is Month or Day

@Ellen

DateTime.ParseExact(StartDate, "dd-MM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("yyyy-MM-dd")

@Ellen

OutputDAte=DateTime.ParseExact(startDate, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

Import System.Globalization

1 Like

Hi @Ellen

startdate = “12-01-2024”

Output=

Datetime.ParseExact(startdate.ToString, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

Output = 2024-01-12

Hope it will helps you :slight_smile:
Cheers!!

Hi ,

Use assign activity and put this on right side
Datetime.ParseExact((“12-10-2024”).ToString, “dd-MM-yyyy”, System.Globalization.CultureInfo.InvariantCulture).ToString(“yyyy-MM-dd”)

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