How to get From date And To date From Read file

hi,
i have one file name is–MNR_MPK Foods India Private Limit_ 1st to 4th Dec’ 2021.

from this i want to get Date

From --01-12-2021

TO --04-12-2021

how to get date like ?

HI @Anand_Designer

Use Assign activity

LHS → Create an variable
RHS → System.Text.RegularExpressions.Regex.Match("InputString","(?<=From\s--)(\d.{2}\d.{2}\d{4})").Tostring

image

Use Assign activity

LHS → Create an variable
RHS → System.Text.RegularExpressions.Regex.Match("InputString","(?<=TO\s--)(\d.{2}\d.{2}\d{4})").Tostring

image

Regards
Gokul

1 Like

Hi @Anand_Designer ,

We could make use of Regex to get the Date values, but we would also need a Confirmation about the Date format.

Will the Date be always in this format ?

Using Regex we can get the First Date and the Complete date format like below :
image

(\d+)\w{2}\sto\s(.*\d)
1 Like

Hi @Anand_Designer

Use Assign activity

LHS → Create an variable
RHS →

System.Text.RegularExpressions.Regex.Match("MNR_MPK Foods India Private Limit_ 1st to 4th Dec’ 2021","(?<=to\s)(\d.{3}\w{3}’\s\d{4})").Tostring

Regards
Gokul

yes the date format come like same above file name, it will change on weekly base Date.
like 5th to 11th Dec’2021

Regex should be the best approach but if you are not comfortable using it you can try to save the file name in a string variable and then do some string manipulation.
How to manipulate a part of string: Split, Trim, Substring, Replace, Remove, Left, Right - News / Tutorials - UiPath Community Forum