How to write query iff statement with datediff function

staholly

Registered User.
Local time
Today, 06:18
Joined
Jul 14, 2011
Messages
16
I need to write a statement that does the following:
If closed date is empty than subtract date opened from today’s date if not subtract closed date from opened date.
 
What have you tried?
 
I tried
iif(isnull([date closed]),datediff("d",date(),[date opened]),datediff("d",[date closed],[date opened])

This is for Acess 2003
 
That looks basically okay, though you missed the parentheses to close off the IIf() function. Try

iif(isnull([date closed]),datediff("d",date(),[date opened]),datediff("d",[date closed],[date opened]))

Does it error, or ?
 

Users who are viewing this thread

Back
Top Bottom