Query Date criteria

J

Jasper Recto

I have a query that has a date criteria that is in a range. For example it
runs from 1/01/08 to 03/31/08.

Is it possible to change the criteria so it always run the past 3 months
from the date is was run. So for example, if I ran it today (07/18/08) the
criteria field would select the last 3 months from today, so 04/18/08 to
07/18/08.

Can you do that in the query?


OR
is it possilbe to have it prompt the user for which quarter of the year to
run?


Thanks,
Jasper
 
T

Tom van Stiphout

On Fri, 18 Jul 2008 08:49:16 -0400, "Jasper Recto"

Yes: use a where clause like this:
where YourDateField between DateAdd('m',-3,Date()) and Date()

-Tom.
Microsoft Access MVP
 
P

pietlinden

I have a query that has a date criteria that is in a range.  For example it
runs from 1/01/08 to  03/31/08.

Is it possible to change the criteria so it always run the past 3 months
from the date is was run.  So for example, if I ran it today (07/18/08)the
criteria field would select the last 3 months from today, so 04/18/08 to
07/18/08.

Can you do that in the query?

OR
is it possilbe to have it prompt the user for which quarter of the year to
run?

Thanks,
Jasper

SELECT Contacts.EMailAddress, Contacts.InterviewDate
FROM Contacts
WHERE (((Contacts.InterviewDate) Between DateAdd("m",-3,Date()) And
Date()));
 
J

Jasper Recto

Works Great, Thanks!

Although, one more question.

If I wanted to prompt the user for the beginning date and the end date, how
would I do that?


Thanks,
Jasper
 
T

Tom van Stiphout

On Fri, 18 Jul 2008 09:18:21 -0400, "Jasper Recto"

where YourDateField between [Give start date:] and [Give end date:]

Or you create a pretty form, and have the query "look back" on it:
where YourDateField between Forms!SomeForm!SomeStartDate and
Forms!SomeForm!SomeEndDate

-Tom.
Microsoft Access MVP
 
J

Jasper Recto

THANKS!!!!


Tom van Stiphout said:
On Fri, 18 Jul 2008 09:18:21 -0400, "Jasper Recto"

where YourDateField between [Give start date:] and [Give end date:]

Or you create a pretty form, and have the query "look back" on it:
where YourDateField between Forms!SomeForm!SomeStartDate and
Forms!SomeForm!SomeEndDate

-Tom.
Microsoft Access MVP


Works Great, Thanks!

Although, one more question.

If I wanted to prompt the user for the beginning date and the end date,
how
would I do that?


Thanks,
Jasper
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top