If Statment with Expression in Query

  • Thread starter Thread starter Darla
  • Start date Start date
D

Darla

I am using the following expression in a query. It works
except that I am getting a negative number. Can anyone
explain why?

Days in Hold: IIf(IsNull([Release Date]),DateDiff("d",Now
(),[Date On Hold]),DateDiff("d",[Release Date],[Date On
Hold]))

Thanks in advance for your help!!
 
Darla,
Wrap your DateDiff function inside an ABS function. That will give you a
positive number regardless of what is returned.

Abs(DateDiff("d",Now (),[Date On Hold]))
 
I am using the following expression in a query. It works
except that I am getting a negative number. Can anyone
explain why?

Days in Hold: IIf(IsNull([Release Date]),DateDiff("d",Now
(),[Date On Hold]),DateDiff("d",[Release Date],[Date On
Hold]))

Thanks in advance for your help!!

Reverse the 2 date fields.
I also suggest you change Now() to Date() unless there is a time of
day value needed elsewhere.

Days in Hold: IIf(IsNull([Release Date]),DateDiff("d",[Date On
Hold],Date()),DateDiff("d",[Date On Hold],[Release Date]))
 
Back
Top