Converting string to date

Good day,

How do I convert my string “18 sept 2023” and “10 oct 2023” to a datetime type.
I tried cdate but it’s not working

thanks in advance

Hi @Mim

Try this:

strinput: “10 oct 2023”
Datetime.ParseExact(strinput.ToString, "dd MMM yyyy", System.Globalization.CultureInfo.InvariantCulture)

Hi @Mim

Try this:

result = DateTime.ParseExact(dateString, “dd MMM yyyy”, System.Globalization.CultureInfo.InvariantCulture)

Hi @Mim

string dateString = “10 oct 2023”
DateTime date = DateTime.ParseExact(dateString, “dd MMM yyyy”, System.Globalization.CultureInfo.InvariantCulture)

Hope it helps!!

@Mim

format = “dd MMM yyyy”
Assign activity: convertedDate = DateTime.ParseExact(inputString, format, System.Globalization.CultureInfo.InvariantCulture)

Hi @Mim

Try the below one to change the datatype from string to datatime datatype.

DateTime.ParseExact(StringVariable, "dd/MMM/yyyy",System.Globalization.CultureInfo.InvariantCulture)

Hope it helps!!

Thank you for all your reply, it works for the oct date, but not for the “18 sept 2023”

it works for the oct date, but not for the “18 sept 2023”

Write the data manipulation to it.

- Assign -> StringVariable(String) = "18 sept 2023"
- Assign -> StringVariable(String) = If(StringVariable.Length=12,StringVariable.Remove(6,1),StringVariable)
- Assign -> Date (DateTime) = DateTime.ParseExact(StringVariable, "dd/MMM/yyyy",System.Globalization.CultureInfo.InvariantCulture)

I have used the data manipulation to remove the t from sept to change from sept to sep.
In second assign I have written the If to check

Hope it helps!!

@Mim

string strDate = “Date”;

// Convert the string to a datetime type.
DateTime dateTime = DateTime.ParseExact(strDate, “dd/MM/yyyy”, CultureInfo.InvariantCulture);

Can you try this…

it looks close to the french short month name, but without ending dot

With the following customization we can reconfigure the the french format:

then we can parse:
grafik

Hi @Mim
Keep all the below syntaxes in Assign activity.

strinput1="18 sept 2023" 

strinput2="10 oct 2023" 

substring_output=If(strinput1.Length=12,strinput1.Remove(6,1),strinput1)

datevar1= DateTime.ParseExact(substring_output, "dd MMM yyyy",System.Globalization.CultureInfo.InvariantCulture)

datevar2= DateTime.ParseExact(strinput2, "dd MMM yyyy",System.Globalization.CultureInfo.InvariantCulture)

Note: strinput1, strinput2, substring_output are of Datatype System.String and datevar1, datevar2 are of the Datatype System.DateTime. Shared the workflow for reference too.

Sequence.xaml (8.3 KB)
Hope it works!!

@Mim

Did it work for you? If yes, Please mark it as solution so that it will help other members in community.

Happy Automation :slight_smile:
Regards,

string.replace(“sept”, “sep”).tostring
DateTime date = DateTime.ParseExact(dateString, “dd MMM yyyy”, System.Globalization.CultureInfo.InvariantCulture)

this is solution for sept dates

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