query for date

  • Thread starter Thread starter clayton ledford
  • Start date Start date
C

clayton ledford

Hello, Hopefully this is an easy one.

I have a date field in my table that updates every time a record is updated
using the "now" function. It shows date and time.

I am also running a query to find anything processed that day. My query is
coming up blank, and i think it's because the fields are date and time, and
my query is for just the date.

How can i fix this in my query? Or... how can i get my Now field to be just
the date?

Clay
 
Using CDate on a value that has date and time results in a value that has
date and time.

Either use DateValue([YourNowField]), or else have the query's criteria be
BETWEEN DateValueUsed AND DateAdd("d", 1, DateValueUsed).

For big tables, the latter is more efficient because it avoids having to
evaluate a function on each row in the table.

Some people are concerned that adding a day to the date could conceivably
bring back data for which the timestamp happens to be exactly midnight of
the next day. While the odds of that happening are very low, you can avoid
the problem by using either

[YourNowField] >= DateValueUsed AND [YourNowField] < DateAdd("d", 1,
DateValueUsed)

or

BETWEEN DateValueUsed AND DateAdd("s", 86399, DateValueUsed)

(there are 86400 seconds in a day)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


KARL DEWEY said:
Try this --
CDate([YourNowField])
--
KARL DEWEY
Build a little - Test a little


clayton ledford said:
Hello, Hopefully this is an easy one.

I have a date field in my table that updates every time a record is
updated
using the "now" function. It shows date and time.

I am also running a query to find anything processed that day. My query
is
coming up blank, and i think it's because the fields are date and time,
and
my query is for just the date.

How can i fix this in my query? Or... how can i get my Now field to be
just
the date?

Clay
 
Back
Top