Connecting Tech Pros Worldwide Help | Site Map

Date Comparison in VB 6.0 and Access.. please help meee

Newbie
 
Join Date: Oct 2009
Posts: 3
#1: Oct 7 '09
hi.. i have a problem about date comparison in VB 6.0 and MS Access

i want to compare dates from access to a date from DTpicker control in VB 6.0.. this is my code but it doesnt work coz i get a syntax error..

"Select * from Reservations where DateCheckIn <= #date1# and DateCheckOut > #date1# and [RoomNo] = ' " & cmb_room & " ' "

"Select * from Reservations where #DateCheckIn# <= #date1# and #DateCheckOut# > #date1# and [RoomNo] = ' " & cmb_room & " ' "

notes:
DateCheckIn and DateCheckOut are access fields with Data Type "Date/Time"
date1 and date2 are Values from my two different DTpickers.
Reservations is my table name

both codes give me a syntax error.. can anyone please suggest a better code?

thnx a lot...
smartchap's Avatar
Familiar Sight
 
Join Date: Dec 2007
Location: Lucknow, India
Posts: 194
#2: Oct 8 '09

re: Date Comparison in VB 6.0 and Access.. please help meee


Visit below link for correction in query (syntax) (use "" before 7 after date1 & date2):
http://www.vbcity.com/forums/topic.asp?tid=32158
I think it will help you solve the problem.
Newbie
 
Join Date: Oct 2009
Posts: 3
#3: Oct 13 '09

re: Date Comparison in VB 6.0 and Access.. please help meee


thnx a lot... this was very helpful... i kept on playing with the syntax.. thnx again..
Reply