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 help with sql 1

Status
Not open for further replies.

FireViking

Programmer
Jun 29, 2001
64
0
0
AU
Hi,
I am trying to create an sql with to criteria. 1. being the region and 2. between dates.

strNotChartCount = "SELECT * FROM tblnotice WHERE Region = #" & strRegion & "# and IssuedDate BETWEEN #" & strStartDate & "# AND #" & strEndDate & "#"

The syntax is not quite right and need assistance.
 
Hi

Assuming Region is not a date type column

If it is a string type:

strNotChartCount = "SELECT * FROM tblnotice WHERE Region = '" & strRegion & "' and IssuedDate BETWEEN #" & strStartDate & "# AND #" & strEndDate & "#"

If it is a numeric:

strNotChartCount = "SELECT * FROM tblnotice WHERE Region = " & strRegion & " and IssuedDate BETWEEN #" & strStartDate & "# AND #" & strEndDate & "#"

and finally, be aware dates must be presented within SQL statemenst in US format, ie mm/dd/yy, so if you are not in the USA you may also need to reformat your dates so:

Format(strStartDate,"mm/dd/yy")

Hope this helps

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
UK
 
Hi,
Thanks for that, I didnt realise I had used the date syntax. Big day and started to get frustrated. Thanks for the tips.

Cheers
:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top