The date/time type in Access treats
#12/12/2003 10:00:00#
to be *after*
#12/12/2003#.
So - as you found - if you filter to the date, it does not include any times
on that date.
Try asking for records up to and including the last second of the day:
"[MyDate] Between #" & Format(Me![BeginDate], "mm\/dd\/yyyy") & _
"# And #" & Format(Me![EndDate], "mm\/dd\/yyyy") & " 23:59:59#"
Alternatively, ask for records that are less than the next day:
"([MyDate] >= " & Format(Me![BeginDate], "\#mm\/dd\/yyyy\#") & _
") AND ([MyDate] < " & Format(Me![EndDate] + 1, "\#mm\/dd\/yyyy\#") & ")"
These solutions are more efficient than using DateSerial() on the field
value. That executes a function call at every row and prevents JET from
using an index on the date field.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Nathan Bloomfield" <nathanbloomfield@hotmail.com> wrote in message
news:4bbc1902.0312222103.5be0ae62@posting.google.c om...[color=blue]
> I am having difficulty filtering dates for a report. I have written
> the following code on a popup form which works with regular date
> fields , however, I am now trying to apply the same concept to a field
> which is formatted as date/time i.e. now()
>
> DoCmd.OpenReport "rptOpenLabels", acViewPreview, , "[MyDate] Between
> #" & Format(Me![BeginDate], "mm/dd/yy") & "# and #" &
> Format(Me![EndDate], "mm/dd/yy") & "#"
>
> The code above does not take into account the 00:00 to 23:59 and must
> default to 23:59 as the filter 22/12/03 to 23/12/03 will result in
> figures for 23/12 but 23/12/03 to 23/12/03 results in an empty report.
>
> Any help will be much appreciated.
>
> Regards,
>
> Nathan[/color]