Calculating in query

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

Guest

I have an assignment to determine the following:
Field:dteClosedate
When I run the query the close date and time was 03/31/2005 8:39:37PM.
I am to run a report that would only display closed items after 96 hours
from the date and time a given item was closed.
How do I set this up in a query to only pull this information after 96 hours.
 
Add this column to your query
HowManyHours: DateDiff("h",[dteClosedate],Date())
and in the Criteria Box put >96
 
Better to put the following criteria on the dteCloseDate Field directly:

< DateAdd( "d", -4, Now() )

This way, Access / Jet only evaluates the DateAdd only _once_. This will
even be much faster if the Field dteClosedDate is indexed.

Using "HowManyHours", the DateDiff will have to be evaluated for each Record
in the Table and the index (if any) will not be used for record selection.

--
HTH
Van T. Dinh
MVP (Access)



Dennis said:
Add this column to your query
HowManyHours: DateDiff("h",[dteClosedate],Date())
and in the Criteria Box put >96

CyndyG said:
I have an assignment to determine the following:
Field:dteClosedate
When I run the query the close date and time was 03/31/2005 8:39:37PM.
I am to run a report that would only display closed items after 96 hours
from the date and time a given item was closed.
How do I set this up in a query to only pull this information after 96
hours.
 
Back
Top