Query for time period

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What do I use in a query to get a date range...say from 1 to 30 days...then
another query for 31-60? I understand this will be two different queries but
what do I have to enter into the date field that I want to sort by.

Thank for the assistance.
 
This will give you what you need, but if you are just wanting a query for the
current month and another query for last month, there is a more precise way
to do that.

For the 1 to 30 days:
Put this in the criteria section of the date field:
=DateSerial(Year(Date()),Month(Date()),-30)

or if you want to do it in SQL, this would be the WHERE condition:

WHERE (((TableName.DateFieldName)>=DateSerial(Year(Date()),Month(Date()),-30))
)

For the 31-60:
Put this in the criteria section of the date field:
=DateSerial(Year(Date()),Month(Date()),-60) And <=DateSerial(Year(Date()),Month(Date()),-31)

or if you want to do it in SQL, this would be the WHERE condition:

WHERE (((TableName.DateFieldName)>=DateSerial(Year(Date()),Month(Date()),-60)
And (TableName.DateFieldName)<=DateSerial(Year(Date()),Month(Date()),-31)))
 
Back
Top