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!

SQL Query Date Variables 1

Status
Not open for further replies.

Enkrypted

Technical User
Sep 18, 2002
663
0
0
US
I have the following code:

Code:
SELECT OptionsValues.AgentAssisted,
       OptionsValues.CurrentDate,
       OptionsValues.Duration
FROM OptionsValues
WHERE OptionsValues.Cable Is Not Null

      -- Bigger or equal of startdate 
      AND OptionsValues.CurrentDate >= '20140421'

      -- Smaller than your end date + 1 day. That way you will get right result if you have time in your datetime fields. 
      AND OptionsValues.CurrentDate <  '20140423' 
ORDER BY OptionsValues.AgentAssisted;

Can the date of 20140421 be replaced with a variable of some kind so that it will input whatever is put into that field? For example, the input box is labeled as frmStartDate, so how would I get it to work like

AND OptionsValues.CurrentDate >= 'frmStartDate'

so that whatever date is put in there will take the place of the original date in the following

AND OptionsValues.CurrentDate >= '20140421'

Any help is appreciated!

Enkrypted
A+
 
The syntax is:
AND OptionsValues.CurrentDate >= [Forms]![Name of form]![Name of control]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you. That helped out alot!

Enkrypted
A+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top