This is my string in excel in column mrkt cmnts
“5-8-24 emailed AM…pt was inmate per call note in ehr lm
_Letter aer to patient bucket…RK”
04/03/2024_Task escalated to review…JS
03/01/2024_Secondary denied as office visit are not covered as per patient plan, hence escalated team for further assistance…SM
03212024_Per web, claim got received and processed and denied deductible not covered. therefore, escalating to team…KC
01/03/2023_Claim denied for invalid code so claim escalated to team for further assistance Cl…SS----i get the date at starting of the string in different formats and i want to extract the date from the string and after extract date from this string i have to check if the date is in between 30 to 45 days older from the current date, if it is in between the 30-45 days from current date than i want to write only those rows in my data table–
Thanks in advance
pattern1 = "\b\d{1,2}-\d{1,2}-\d{2,4}\b" ' matches formats like 5-8-24
pattern2 = "\b\d{2}/\d{2}/\d{4}\b" ' matches formats like 04/03/2024
pattern3 = "\b\d{8}\b" ' matches formats like 03212024
@rlgandu
ok, can i put this pattern as a whole where i coverd all formats
Also check other condition also
Hi @Arvind1
You can use below regex expression:
([0-9]{1,2}[-\/][0-9]{1,2}[-\/][0-9]{2,4})|[0-9]{8}
Hope it helps!!
string[] dateFormats = { "M-d-yy", "MM/dd/yyyy", "MMddyyyy" };
string[] parts = comment.Split(new[] { ' ', '_', '-' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var part in parts)
{
if (DateTime.TryParseExact(part, dateFormats, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date))
{
// Check if the date is within the specified range
return date >= startDate && date <= endDate;
}
}
return false;
}).ToList();
Thanks,
i make the regex part
i want if the date i extract is between 30-45 days older
Loop for each on Ienumerable of matches of dates
TodayMinus30=DateTime.Today.AddDays(-30)
TodayMinus45=DateTime.Today.AddDays(-45)
DateValue=DateTime.ParseExact(DateString, { "M-d-yy", "MM/dd/yyyy", "MMddyyyy" }, CultureInfo.InvariantCulture)
<If Condition="(DateValue >= TodayMinus45) And (DateValue <= TodayMinus30)">
Hope this will helps you
Hi @Steven_McKeering
Thanks, its work
Hie @Arvind1 here is the approach you can use to get the dates from your input
i"m attaching screenshot to understand how you get the multiple dates.
your input string
use find matching patterns activity and pass the input string variable

Find matching patterns - variable is a collection variable as you see i"m using in for each activity .
mark this solution if you find it was helpful.
cheers Happy Automation