Compare dates (after or before a referral date)

Hi, I need to know if a date is after or before another one. For example if 23/11/2023 is sooner than 22/10/2023. Is there any activity/method to do it?

Thank you

Hi @mmarcos

Try this syntax:

result= DateTime.Compare(DateTime.ParseExact("23/11/2023", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture), DateTime.ParseExact("22/10/2023", "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture))

If 
   result < 0
Then
    Log Message-> "First date is before the second date"
Else
    Log Message-> "First date is after or the same as the second date"

Hope it helps!!

@mmarcos
Assign : date1 = DateTime.ParseExact(“23/11/2023”, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture)
date2 = DateTime.ParseExact(“22/10/2023”, “dd/MM/yyyy”, System.Globalization.CultureInfo.InvariantCulture)

comparisonResult = DateTime.Compare(date1, date2)

If comparisonResult < 0 Then
’ date1 is earlier than date2
’ Perform actions accordingly
LogMessage(“date1 is earlier than date2”)
ElseIf comparisonResult > 0 Then
’ date1 is later than date2
’ Perform actions accordingly
LogMessage(“date1 is later than date2”)
Else
’ date1 and date2 are equal
’ Perform actions accordingly
LogMessage(“date1 and date2 are equal”)
End If

@mmarcos

isAfter = DateTime.Compare(DateTime.ParseExact("23/11/2023", "dd/MM/yyyy", CultureInfo.InvariantCulture), DateTime.ParseExact("22/10/2023", "dd/MM/yyyy", CultureInfo.InvariantCulture)) > 0

Hi @mmarcos

Check this:

Hope it helps!!