Remove string and convert the remaining text to date

Hi, I guess this is a very simple ting, but I still manage to get stuck. In col 0 in a datatable, each row has a string similar to this:

Tuesday, 14-MAY-2022 (All text)

I need to delete everything before the date part, and then convert the text formatted date to a real date.

Anyone?

Hi @Botter

You can try with Regex expression

System.Text.RegularExpressions.Regex.Match(Currentrow("ColumnName").Tostring,"\d{2}-\S.*-\d{4}").Tostring

image

Check out this tutorial and thread for chamging the date format in excel file

Regards
Gokul

Hi @Botter ,

Can you try this,

str = Tuesday, 14-MAY-2022

dateTimeVar = DateTime.ParseExact(str.Split(","c)(1),“dd-MMM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)

Hi @Botter

Alternative Method, It will gives you only the date.

DateTime.ParseExact(Currentrow("ColumnName").Tostring,"dddd, dd-MMM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd-MM-yyyy")

Regards
Gokul

And this I should use in a “For Each Row In Data Table” activity?

Yes, You need to use For each row in Data Table activity

OK, thank you very much for your time and sharing your knowledge all of you!