# Query Criteria Problem

• ### Question

• I have two fields - one is date 1 and the other is date 2.  The fields are formatted for date and time.  I need to create a query that date 1 is created than the date 2 by more than 3 hours, to display those records.  Is it possible to have in a query??
Wednesday, October 28, 2015 5:11 PM

• I have two fields - one is date 1 and the other is date 2.  The fields are formatted for date and time.  I need to create a query that date 1 is created than the date 2 by more than 3 hours, to display those records.  Is it possible to have in a query??

Hi seebert,

You could use something like:

WHERE (date2 - date1) > 3 / 24

or

WHERE date2 > date1 + 3 / 24 (3 hours out of 24)

Imb.

• Marked as answer by Thursday, October 29, 2015 3:01 PM
Wednesday, October 28, 2015 6:06 PM

### All replies

• I have two fields - one is date 1 and the other is date 2.  The fields are formatted for date and time.  I need to create a query that date 1 is created than the date 2 by more than 3 hours, to display those records.  Is it possible to have in a query??

Thanks,

RM

Wednesday, October 28, 2015 5:56 PM
• I have two fields - one is date 1 and the other is date 2.  The fields are formatted for date and time.  I need to create a query that date 1 is created than the date 2 by more than 3 hours, to display those records.  Is it possible to have in a query??

Hi seebert,

You could use something like:

WHERE (date2 - date1) > 3 / 24

or

WHERE date2 > date1 + 3 / 24 (3 hours out of 24)

Imb.

• Marked as answer by Thursday, October 29, 2015 3:01 PM
Wednesday, October 28, 2015 6:06 PM
• Or --

WHERE date2 >= DateAdd("h", 3, date1)

Build a little, test a little

Wednesday, October 28, 2015 8:41 PM
• >>>I need to create a query that date 1 is created than the date 2 by more than 3 hours, to display those records.  Is it possible to have in a query??

According to your description, I suggest that you could use the Access DateDiff function that returns the difference between two date values, based on the interval specified.

You could refer to below code:

[code]

WHERE DateDiff("h", date1, date2)>=3

[/code]

Thursday, October 29, 2015 9:27 AM
• WHERE DateDiff("h", date1, date2)>=3

Hi,

The use of functions in queries  _can_  slow down the speed.

Imb.

Thursday, October 29, 2015 1:41 PM
• Thank you for all the help - with your expertise, I got my query working!!!

Thursday, October 29, 2015 3:01 PM