Datediff is not working for me

I am using DateDiff(DateInterval.Day, todaysDate, taskDate)

where todaysDate variable gets Today’s date in DateTime format and taskDate gets date from an excel sheet in DateTime format

I want to see if a task has been updated from last 5 days or not.

Please help.

grafik
grafik

Hi @Nikhil_kathpalia ,

Did you mean to say that you are getting negative values?

image

If so, then you could use a Math.Abs like so:
image

Math.Abs(DateDiff(DateInterval.Day,today,today.AddDays(-1)))

Kind Regards,
Ashwin A.K

I am getting this compiler error

just inspect the datatype of your variable which gets assigned from the statement

maybe you are looking for this:
grafik

1 Like

Hi @Nikhil_kathpalia ,

Somehow I get the feeling that you have placed this inside of an If Activity.
If that is the case, then could you try this?

Math.Abs(DateDiff(DateInterval.Day,today,today.AddDays(-1)))<5

Kind Regards,
Ashwin A.K

1 Like

This worked, Thanks a lot!!

1 Like

kindly note:
grafik
a future date will be kept as same as an 2 days old day with the Math.Abs approach

1 Like

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