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

Between Statement with Dates

Status
Not open for further replies.

ironmunk

Technical User
Aug 21, 2001
51
CA
I need assistance with the following problem. I'm trying to restrict my querys to withing 2 dates.

select * from DB where DATESTAMP between '01-01-01' and '01-03-01'

Thats the command I use, but the dates are from variables. Everytime I try this I get a data type mismatch. Can anyone tell my how to use dates with VB to a DB?
 
You need to surround your dates with the pound sign #
 
Could you please post an example. Would it be this?

select * from DB where DATESTAMP between #'01-01-01'# and #'01-03-01'#
?
or does the # replace the '?
 

Repalce the ' with #. Terry L. Broadbent
faq183-874 contains some tips and ideas for posting questions in these forums. Please review it and comment if you have time.
NOTE: Reference to the FAQ is part of my signature and is not directed at any individual.
 
If your dates are coming from text boxes on a form,

"datestamp between #" & txtStartDate & "# and #" & txtEndDate & "#"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top