How to compare two dates where we can check one date is greater than other in C#

hello

how to compare two dates where we can check one date is greater than other in C#
language

thanks

@nikhil.chandre,

Use this way in If activity.

dtOne.Date > dtTwo.Date

Thanks,
Ashok :slight_smile:

1 Like

Hi @nikhil.chandre

If your values are in the format of DateTime objects then you can use > or < to compare dates .
If not then convert them to DateTime and compare , it will yield the output.

can you elaborate what data type is dtone. is it a string or ?

how can we convert it into datetime obj. can you share the syntax

had used the syntax
DateTime.ParseExact(deadlineDate,“MM/dd/yyyy” , System.Globalization.CultureInfo.InvariantCulture)

giving compile error
image

Hi @nikhil.chandre

@nikhil.chandre,

It’s not datatype it’s just a variable name. Datatype of the variable would be datetime.

Thanks,
Ashok :slightly_smiling_face:

how can we provide value to date time object

thanks

still if condition is not working , the execution flows comes out of the if scope

Hello Nikhil,

Please refer this How to Compare two date - Help - UiPath Community Forum

Regards

@nikhil.chandre

Please share your if condition. Here 08/23/2024 is the big date.

Thanks,
Ashok :slightly_smiling_face:

Can you show us deadLineDate value?

Hello @nikhil.chandre,

Try below steps

  1. Assign Activity: deadLineDate = “4/15/”+DateAndTime.Now.Year
  2. Assign Activity: todayDate = DateAndTime.Now.Today
  3. If Condition: Cdate(deadLineDate) > Cdate(todayDate)

Regards,
Pradeep Shiv