Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date query with null values 1

Status
Not open for further replies.

Smack

Technical User
Apr 20, 2001
261
US
In a query i want to show how many days an action has been open. I have 2 date fields, opened closed.
Using Expr1: ([Closed])-([Opened])is easy for records which have been closed, but how to calculate opened to current dat if the closed field is null?
-Smack >::O>
 
Use the IIf and datediff functions.

Expr1: datediff("d", IIf([Closed] Is Null, date(), [Closed]), [Opened])

The IIf functions substitutes today's date for [Closed] if [Closed] is null. You can use that expression in your datediff calculation. This will calculate the number of days between the dates. Terry
 
Excellent!Copy Paste and BAM!!
Thanks alot.
-Smack
 
As usual, now that I have added that to the report, "they" want something else!
In using the above expression, how would I tie in a third date field, Date Due, to calculate not only the days open, but also days past due for when the date closed surpasses date due? LOL
 
Once again - BAM! (Don't know why I'm on this Emeril thing)
One other question, The expressions give days open and overdue days as negative numbers. How to transpose?
-Smack
 
Thank you Terry, that worked great.
Smack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top