How to convert such date format 18-Apr-2024 to DD/MM/YYYY, and to check if this date is earlier than another date?

how to convert such date format 18-Apr-2024 to DD/MM/YYYY, and to check if this date is earlier than another date?

@beginner_RPA
image

DateTime.ParseExact("18-Apr-2024","dd-MMM-yyyy",System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")
Assign: otherDate
Value: DateTime.ParseExact("AnotherDate", "dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

If (parsedDate < otherDate)
    Then
        // First date is earlier than the other date
    Else
        // First date is later than or equal to the other date

Hi @beginner_RPA

Try this:

Assign activity -> anotherDate = "04/29/2024"

Assign activity -> convertedAnotherDate = DateTime.ParseExact(anotherDate, "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

Assign activity -> originalDate = "18-Apr-2024"

Assign activity -> convertedOriginalDate = DateTime.ParseExact(originalDate, "dd-MMM-yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd/MM/yyyy")

If
   convertedOriginalDate < convertedAnotherDate
Then
    Log Message "The converted date is earlier than the other date."
Else
    Log Message "The converted date is not earlier than the other date."
End If

Variable Types:

Output:
image

Sequence22.xaml (9.7 KB)

Hope it helps!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.