Need a Latest date from the string

hi
i have a text,

@"Electronically Signed By: Breanna Anderson, PT, License 070024649 July 3, 2024 4:39 PM

Electronically Signed By: Viviana Saavedra, PTA, License 160010120 July 3, 2024 12:10 PM"

In this text i need a latest date which is “july 3 2024 4:39 PM” → can u please make some logic and share it with me

@katta_nikhil


"(\w+ \d{1,2}, \d{4} \d{1,2}:\d{2} [AP]M)"
dateList=Matches.Select(Function(m) DateTime.ParseExact(m.Value, "MMMM d, yyyy h:mm tt", System.Globalization.CultureInfo.InvariantCulture)).ToList()
dateList.Max.ToString("MMMM d, yyyy h:mm tt")

Hi @katta_nikhil

You can use the below expression to get the recent date in the above text,

- Assign -> Input = "Electronically Signed By: Breanna Anderson, PT, License 070024649 July 3, 2024 4:39 PM

                     Electronically Signed By: Viviana Saavedra, PTA, License 160010120 July 3, 2024 12:10 PM"

- Assign -> Output = System.Text.RegularExpressions.Regex.Matches(InputText.ToString(), "[A-Za-z]+\s*\d+,\s+\d+\s*\d+\:\d+\s*[AM|PM]+").Cast(Of System.Text.RegularExpressions.Match)().Select(Function(X) X.Value).ToList.max(Function(X) CDate(X)).toString("MMMM d,yyyy h:m tt")

Check the below image for better understanding,

Hope it helps!!

Hi @katta_nikhil

inputText = @"Electronically Signed By: Breanna Anderson, PT, License 070024649 July 3, 2024 4:39 PM

Electronically Signed By: Viviana Saavedra, PTA, License 160010120 July 3, 2024 12:10 PM"

matches = System.Text.RegularExpressions.Regex.Matches(inputText, "July \d{1,2}, \d{4} \d{1,2}:\d{2} (?:AM|PM)")

Create a variable latestDateTime As DateTime

For Each match In matches
    dateString = match.Value
    dateTime = DateTime.ParseExact(dateString, "MMMM d, yyyy h:mm tt", System.Globalization.CultureInfo.InvariantCulture)

    If dateTime > latestDateTime Then
        latestDateTime = dateTime
    End If
Next

Messagebox latestDateTime.ToString

Hope it helps!!

Yeah i got a solution but , based on the latest date i need to pick up the name of that signed person
I.e ; Breanna Anderson

Hi @katta_nikhil

Can you try the below

Sequence10.xaml (16.6 KB)

Output:

image

Regards,

Okay @katta_nikhil

You want to get the Signed person name which is signed recently. Am I right.

If yes, then use the below two LINQ Expressions to achieve it,

- Assign -> Input = "Electronically Signed By: Breanna Anderson, PT, License 070024649 July 3, 2024 4:39 PM

                     Electronically Signed By: Viviana Saavedra, PTA, License 160010120 July 3, 2024 12:10 PM"

- Assign -> RecentDate = System.Text.RegularExpressions.Regex.Matches(InputText.ToString(), "[A-Za-z]+\s*\d+,\s+\d+\s*\d+\:\d+\s*[AM|PM]+").Cast(Of System.Text.RegularExpressions.Match)().Select(Function(X) X.Value).ToList.max(Function(X) CDate(X)).toString("MMMM d,yyyy h:m tt")

- Assign -> SignedPerson = System.Text.RegularExpressions.Regex.Match(System.Text.RegularExpressions.Regex.Matches(Input, ".*").Cast(Of System.Text.RegularExpressions.Match)().ToList().Where(Function(entry) entry.Value.Contains(RecentDate.ToString)).FirstOrDefault().ToString, "(?<=Electronically Signed By\:\s*)[A-Za-z\s]+").Value

Check the below workflow for better understanding,
Sequence4.xaml (9.3 KB)

Hope it helps!!