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

Where dateA > dateB and dateA < dateC in SQL ???

Status
Not open for further replies.

thewizz

IS-IT--Management
Nov 30, 2003
12
0
0
CA
Ho do i COmpare dates in access SQL ?
My DateA is a field in a Table
DateB & DateC are dates in a Form

(Im doing a FInd form that opens aother form on a button press & i pass the WHERE statement in the stLinkcriteria of OpenForm function)


thewizz
 
Hi

If you are building the SQL string in code then

strSQL = &quot;...whatever.. WHERE DateA > #&quot; & DateB & &quot;# AND DateA < #&quot; & DateC & &quot;#;&quot;

Note however Access in SQL strings expects dates to be in US format, no matter what the locale settings of the PC, if you are not in the US you may need to slightly modify this to force US style mm/dd/yy so

Format(DateB,&quot;mm/dd/yy&quot;) and similarly for DateC







Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Also, it can be slightly simplified:

strSQL = &quot; WHERE [DateA] Between #&quot; & DateB & &quot;# and #&quot; & DateC & &quot;#;&quot;





MichaelRed
m.red@att.net

Searching for employment in all the wrong places
 
PROBLEM SOLVED! Opss caps..
thanks it has worked !

thewizz
 
> Note however Access in SQL strings expects dates
> to be in US format, no matter what the locale settings
> of the PC, if you are not in the US you may need to
> slightly modify this to force US style mm/dd/yy

that's not quite right

access has no problem whatsoever with the ISO standard format yyyy-mm-dd

in fact no database i'm aware of has any trouble with that format, so why take the chance on getting mm/dd mixed up with dd/mm?

nice that it's a standard, too

rudy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top