View Full Version : Counting Date and Time with variables


Scottie31
02-20-2007, 10:21 AM
I am currently running a query which shows a date and time for several products:

Product 1 Product 2 Product 3 Product 4
01/01/07 12:00 01/01/07 15:25 01/01/07 15:25 01/01/07 17:36


From this information I need to count each Product unless the date & time is equal or within 30 minutes.

Any help on this one would be greatly appreciated.

gblack
02-20-2007, 12:29 PM
I am currently running a query which shows a date and time for several products:

Product 1 Product 2 Product 3 Product 4
01/01/07 12:00 01/01/07 15:25 01/01/07 15:25 01/01/07 17:36


From this information I need to count each Product unless the date & time is equal or within 30 minutes.

Any help on this one would be greatly appreciated.

Do you mean within 30 minutes of when you run the query... or within 30 minutes of each other... or within 30 minutes of product 1???

gblack
02-20-2007, 01:16 PM
This will put a 1 in the colmun if the time is within 30 minutes of now and a zero in the column if it is greater. Then you simply sum it to get a total count.

CountProduct1: IIF(DateDiff("n",[Product 1],Now())<=30, 1, 0)

If you want to reference it against someting other than now... just change the Now() to one of your other fields...

CountProduct2: IIF(DateDiff("n",[Product 2],[Poduct 1])<=30, 1, 0)

Just a thought.