Split Date from the Date Named Excel

I have an excel file that named “KART_RAPOR_20221212-orj.xlsx” and I need to seperate the date.

In the next steps, I check the dates from the excel in the format “datetime.ParseExact(CurrentRow(“duedate”).ToString ,“dd.MM.yyyy”,system.Globalization.CultureInfo.InvariantCulture,system.Globalization.DateTimeStyles.None)” And for last step I will compare the times with the date that I got from the excel name.

So I need the split the excel name, get the date and convert it to right format. I need help, please…

Hi @ozhazdayt ,

Could you let us know more details of the pattern that could be found in the filenames ?
For an initial check, maybe use the below regex :

(?<=_)\d+(?=\-)

Expression :

dateValue = System.Text.RegularExpressions.Regex.Match(InputFileNameVar,"(?<=_)\d+(?=\-)").Value.Trim

Here, dateValue is a variable of String type.

Conversion to Date :

Datetime.ParseExact(dateValue ,"yyyyMMdd",System.Globalization.CultureInfo.InvariantCulture)

Let us know if you need further help or the above doesn’t work.

Hi @ozhazdayt ,

Can you try this,

str = “KART_RAPOR_20221212-orj.xlsx”

outStr = DateTime.ParseExact(System.Text.RegularExpressions.Regex.Match(str,“(?<=_)\d+(?=-)”).ToString,“yyyyMMdd”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd.MM.yyyy”)

Thanks!

HI @ozhazdayt

You can try with Regex expression

DateSplit = System.Text.RegularExpressions.Regex.Match("ART_RAPOR_20221212-orj.xlsx","(?<=\w)\d.*(?=\-)").Tostring

image

Then you can try with Date expression

Outdate = DateTime.ParseExact(DateSplit.ToString.Trim,"yyyyMMdd",System.Globalization.CultureInfo.InvariantCulture)

Regards
Gokul

@ozhazdayt

As per this Input = KART_RAPOR_20221212-orj.xlsx based on your requirement Output = 20221212

Please find the attached flow is solution for your requirement
Test_Sequence.xaml (6.1 KB)

Thanks
Varun