Date Parameter

B

buzzandbeyond

Hi,

I have a field in a table that is dd/mm/yy hh:mm:ss and I need to
return everything that is for today's date. I tried using date() but
this does not work.

Any tips?

Cheers
Dave
 
J

Jeff Boyce

Dave

Are you saying your field had both date & time in it (you described a
format, not the contents).

If you want to find all the records where a date/time value has today's
date, you need to "calculate" the date-portion of the field. In your query,
you could use a (new) field something like:

NewField: DateValue([YourTablesDateTimeField])

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
K

KARL DEWEY

Using Date() it has the the date and time as of midnight. You will need
to strip the time off of your data to match.

Try this --
Int([YourDateTimeField])

Then use criteria of Date() to select your records.
 
J

John Vinson

Hi,

I have a field in a table that is dd/mm/yy hh:mm:ss and I need to
return everything that is for today's date. I tried using date() but
this does not work.

That's because #7/31/2006 00:00:00# is the value of Date(), and that
will not match #7/31/2006 11:21:46# which might be in your table.

Either use DateValue([datefield]) as a calculated field, or - to take
advantage of any index on the date field - use a criterion of
= Date() AND < Date() + 1

John W. Vinson[MVP]
 
J

John Vinson

Plus one what <g>?

Plus one day... overreliance on the implementation, of course!

Your idea would be fine if you can count on no data DURING the last
second - date/time values can contain sub-second data but not display
it. Unlikely I know!

Cleaner would be
= Date() AND < DateAdd("d", 1, Date())

John W. Vinson[MVP]
 
Top