Get the difference between time and compare it with certain month

I have three variable here. All three are in a DateTime formate, Lets say date1, date2, date3
I wanted to get the difference and compare it with date3. So, what I did I subtracted date1 - date2 which gave me a variable date4 which has a TimeSpan format. I wanted to compare this with date3.AddMonths(24)

so I wanted to check how can I compare a timeSpan value with a DateTime. I feel like i cannot compare but Is there any alternative way ?

@Rajat_16 Can you tell us what is the Output that you expect when you subtract all 3 dates?

1 Like

a Boolean value, compare and find out if the condition

hi @Rajat_16

lets give sample dates for date1, date2 and date3

after getting difference date1-date2 - result time span ?

tell the condition manually? and provide result for the sample input dates.


1 Like

(date1 - date2) < date3.AddMonth(24) - This will return a boolean expression right?

1 Like

@Rajat_16 Can you tell us what you are actually doing ? It would help us to understand the problem better :sweat_smile:, Also if you Consider Date2 as 08-05-2020 and Date1 as 07-05-2020, What output do you expect when Date2- Date1 is performed. Based on this answer we can provide you a Solution

1 Like

So I have a list of dates and I am iterating in that list of dates and getting date1. I have a date2 already set to a date.

Now, all I am doing is calculating the difference between date1 - date2 or either way date2 - date1. now from this I have get a output which is in timespan. I wanted to compare if this timespan is < or > 24 months

This is what I am trying to do

CompareTimeSpan.xaml (5.7 KB)

Try this…! @Rajat_16