Identify the latest time from two strings

Hello Team,

I had two strings like :
strStart="AR_Invoice 20112023102553
strEnd="AR_Invoice 20112023102554

in the above 2 strings the format is like, AR_Invoice (DateFormat)(TimeFormat)
i have to identify which is the latest one based on the time format.

any responses are appreciated.


Hi @shivarajvp555 ,

Could you maybe check with the below Expression :



If the Above Expression results in false, it would mean the str2 is greater/latest

Hi @shivarajvp555

dateTimeStart = DateTime.ParseExact(strStartDateTime, “yyyyMMddHHmmss”, System.Globalization.CultureInfo.InvariantCulture)
dateTimeEnd = DateTime.ParseExact(strEndDateTime, “yyyyMMddHHmmss”, System.Globalization.CultureInfo.InvariantCulture)

Use IF activity

If dateTimeStart > dateTimeEnd
latestDateTime = dateTimeStart
latestDateTime = dateTimeEnd

Hi @shivarajvp555

Try this:

strStart = "AR_Invoice 20112023102553"
strEnd = "AR_Invoice 20112023102554"

timeFormatStart = DateTime.ParseExact(strStart.Substring(strStart.Length - 12), "HHmmss", System.Globalization.CultureInfo.InvariantCulture)
timeFormatEnd = DateTime.ParseExact(strEnd.Substring(strEnd.Length - 12), "HHmmss", System.Globalization.CultureInfo.InvariantCulture)

If timeFormatStart > timeFormatEnd Then
    result = "strStart is the latest."
ElseIf timeFormatStart < timeFormatEnd Then
    result = "strEnd is the latest."
    result = "Both have the same time."
End If


timeFormatStart and timeFormatEnd are of Datatype System.DateTime

Hope it helps!!

Hi @supermanPunch

Can you please help me to understand what is this logic you built Please.

Thanks @sanjay3 .
This solution also worked.

@shivarajvp555 ,

The Expression could be broken down into two parts :

Date Value Extraction Expression :


Conversion of String Date to Date Time type (For Comparison) :

DateTime.ParseExact(`Output From Regex Matche`,"ddMMyyyyhhmmss",System.Globalization.CultureInfo.InvariantCulture)