Date calculations in Access ?

  • Thread starter Thread starter Andres
  • Start date Start date
A

Andres

Hello

I am using Access 2002, I have a DB where I would like to
query only those records which are 30 days old from today
can someone give me an example of how I would query a
date field where it would use system date and show
records that are 30 days old.

My date field is called "RequestDate"

Thank you
Xavier
 
1. Create a query.

2. Drag RequestDate into the grid.

3. In the Criteria row under this field, enter:
 
In the criteria of the date field, you want something like
where datediff(record and now()) >30

summit like that - check the date diff function in the
expresion builder
 
Thank you it worked, I see why it didn't work for me I
never gave it a sign like = > <.
Would there be a simple way to prompt the user for a
number (# of days)?

Thanks
Andres
 
Hello

I am using Access 2002, I have a DB where I would like to
query only those records which are 30 days old from today
can someone give me an example of how I would query a
date field where it would use system date and show
records that are 30 days old.

My date field is called "RequestDate"

Thank you
Xavier

You can create a Query using one of Access' numerous date functions as
a criterion. in this case, just type

< DateAdd("d", -30, Date())

on the Criteria line under RequestDate; the Date() function returns
the system clock date, and the DateAdd function will add -30 days
(subtract thirty days, that is).
 
Use criteria of:
Date() - [How Many Days Ago?]

That will work as is, but it is a good idea to declare it as a parameter. In
query design view, choose Parameters on the Query menu, and enter this into
the dialog:
[How Many Days Ago?] Long
That way, Access will only accept a numeric value when it prompts.
 
Back
Top