Compare date field to today's date

G

Gryzor

Hello people!

I have a question which is probably easier than I think, but I still haven't
found a satisfactory enough way to do it...

In each record I have a field date. I want to be able to create a report of
those records whose date is either within a week from today or past today.
How would I go about doing this? Is it possible to have a yes/no box in each
record which would be automatically checked when the record's date is past
today?

Thanks in advance!
Th
 
A

Allen Browne

Open in design view the query that is the RecordSource for the report.

In the Criteria row under the date field, enter:
< Date() + 7
or possibly
Date() - 7

I wasn't clear from your post which of these you wanted.
 
B

Brendan Reynolds

The following query would select the required records ...

SELECT TheTable.*
FROM TheTable
WHERE (((TheTable.TheDate)>Date() Or (DateDiff("d",[TheDate],Date())<7)));

Where 'TheTable' is the name of your table, and 'TheDate' is the name of
your date field.

This assumes that no time part has been entered in the field. It would need
modification if a time part has been entered.

--
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com

The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
 
Top