Hi,

I have a table with curdt field with datatype datetime in ms-access. the entries in curdt as follows:1/28/2011, 2/9/2011 etc.

I have a form with two datepickers with custom format of dd/mm/yyyy.
my query is like

select * from table where curdt between #dtfr# and #dtto#

where dtfr= datepicker1.text and dtto= datepicker2.text
I have a problem that when i select records from table only records that have entries are displayed. e.g
I have entries for 14 jan 2011 and 15 jan 2011
when i select 8 jan 2011 in from dtpicker and 15 feb 2011 in to dt picker i did not get result. even i have records in between that time period.

I hope i put my issue clear.
Please help
Thanks

Recommended Answers

All 4 Replies

You should have to use Value property of DateTimePicker control.

Dim dtfr, dtto as Date
dtfr=DateTimePicker1.Value
dtto=DateTimePicker2.Value
str="select * from table where curdt between #" & dtfr & "# and #" & dtto & "#"

Thanks for the reply, but if both dtfr and dt to have same value i did not get result , well result is there for that date in database

Thanks
solved the prob with

dtfr=DateTimePicker1.Value.date

dtto=DateTimePicker2.Value.date

Dear All,

Pl. try to pass your date value for a criteria withing Between keyword for a date as given below:
(between #" & dtfr.ToString & "# and #" & dtto.ToString & "#)

Working successfully and this is true that It will not retrieve any result if FromDate and ToDate are the Same. For this you may try now() function.

Thnx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.