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

How to code DB2 Pass Thru with date variables

Status
Not open for further replies.

ToyFox

Programmer
Jan 24, 2009
161
US
I am trying to get a pass thru query to work. Eventually I intend to pass two dates to a function and build a pass thru that utilizes the dates. However, how do I substitute
the date values for the hard coded values in the following SQL.... thanks ... the following code works until I start playing with the date values!!!.


SELECT OPEN_DT, ACCOUNT_NO, BRANCH_NO FROM TB
WHERE OPEN_DT >= '11/1/2009' AND OPEN_DT <= '11/30/2009' GROUP BY OPEN_DT, ACCOUNT_NO, BRANCH_NO HAVING BRANCH_NO IN ('102','105', '021') ORDER BY OPEN_DT;
 

Hi,
Code:
SELECT OPEN_DT, ACCOUNT_NO, BRANCH_NO 
FROM TB
WHERE OPEN_DT >= DATE('11/1/2009')
  AND OPEN_DT <= DATE('11/30/2009') 
GROUP BY OPEN_DT, ACCOUNT_NO, BRANCH_NO              
HAVING BRANCH_NO IN ('102','105', '021') 
ORDER BY OPEN_DT;


Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Thanks for the response...but I probably wasn't too clear.
I want to use variables like todate and fromdate instead of the hard coded date values 11/1/2009 and 11/30/2009.
 
I would use a little DAO code to change the SQL property of the saved pass-through query.

Code:
   Dim strSQL as String
   strSQL = "SELECT OPEN_DT, ACCOUNT_NO, BRANCH_NO FROM TB ..."
   Currentdb.QueryDefs("qsptMyPT").SQL = strSQL

Duane
Hook'D on Access
MS Access MVP
 


Code:
WHERE OPEN_DT >= CURRENT DATE
  AND OPEN_DT <= CURRENT DATE + 20 DAYS

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top