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

Date Comparison

Status
Not open for further replies.

elvenmaiden

Programmer
Apr 25, 2002
31
US
Am trying to compare a date time picker value to a date field in access, but cannot come up with the right syntax. Would appreciate any suggestions

i.e. .Open "Select * from tblDate where EffectiveDate = # & dtpEffectiveDate.Value & #

This syntax does not retreive any records.

Also tried to set the dtpEffectiveDate.Value to a date variable and use that in the Select statement and tried assigning DATEVALUE(dtpEffectiveDate.Value) to the variable and used this in the select.

Thanks for any help
 
Are you sure you have the field in Db as data type "Date"

Anyway, this is what worked for me.

It searches for dates between, but I'n sure you might find it usefull

Where (Group = '" & lstGroups.List(i) & "') AND (Date BETWEEN #" & date1.Value & "# AND #" & date2.Value & "#)"

**********************************
May the Code Be With You...
----------
x50-8 (X Fifty Eigt)
 
Try This:

[tt]
.Open "Select * from tblDate where EffectiveDate = #" & format(dtpEffectiveDate.Value,"mm/dd/yyyy") & "#
[/tt]

Or:

[tt]
.Open "Select * from tblDate where EffectiveDate = #" & cdate(dtpEffectiveDate.Value) & "#
[/tt]

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top