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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to query two date fields

Status
Not open for further replies.

Klssri

MIS
Nov 5, 2001
62
0
0
US
I have a simple database I am working on, but need some help pulling out some information. We want to be able to pull records for clients whose case was open during a specific quarter and/or fiscal year, using a parameter. We have a case opening date field and a case closing date field. We want to see all cases that were open during the quarter, Case Closing date would be null, and all cases that closed during the quarter. I think I could use an iff statement to do this, but not sure. Also where would I put the parameter as the case could have actually opened before the start of the quarter, so I really can't use case open date. Is there a way to do this? (if this makes any sense).
 
You probably need multiple conditions in the WHERE clause
Code:
PARAMETERS [Enter The Year] Integer, [Enter The Quarter] Integer;

SELECT ...
FROM ...

WHERE
   10*Datepart("yyyy",[OpenDate]) + DatePart("q",[OpenDate]) <= 
   10*[Enter The Year] + [Enter The Quarter]

   AND 

   (10*Datepart("yyyy",[CloseDate]) + DatePart("q",[CloseDate]) >= 
    10*[Enter The Year] + [Enter The Quarter]
    OR [CloseDate] IS NULL)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top