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!

Problems With Dates...

Status
Not open for further replies.

mitch77

Programmer
Nov 16, 2000
42
0
0
PT
Hi,
Why this Don't Work??

sqlstr = &quot;SELECT * FROM users where [birthdata] >= &quot; & birthdate1 & &quot; and [BirthDate] <= &quot; & birthdate2

Set rst = dbs.OpenRecordset(sqlstr)

This always return 0 records, where birthdate1 and birthdate2 are a textfield form!!

Thanks,
Mitch
 

Minor problem. Add # to query to delimit dates.

sqlstr = &quot;SELECT * FROM users where [BirthDate] >= #&quot; & birthdate1 & &quot;# and [BirthDate] <= #&quot; & birthdate2 & &quot;#&quot;
Terry
------------------------------------
People who don't take risks generally make about two big mistakes a year. People who do take risks generally make about two big mistakes a year. -Peter Drucker
 
In my opinion, you should put quotes in the string:
sqlstr = &quot;SELECT * FROM users where [birthdata] >= ''&quot; & birthdate1 & &quot;'' and [BirthDate] <= ''&quot; & birthdate2 & &quot;''&quot; John Fill
1c.bmp


ivfmd@mail.md
 
tlbroadbent has the right answer although there may be 1 more problem.
If your regional settings are dd/mm/yy then you have to swap the dates day and month around when you pass it to the query. It must be mm/dd/yy.
I wrote a swap date function to fix this problem.

S_Date = Month([start date]) & &quot;/&quot; & Day([start date]) & &quot;/&quot; & Year([start date])

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top