Solved Query criteria between two hour/decimal numbers (1 Viewer)

oxicottin

Learning by pecking away....
Local time
Today, 11:55
Joined
Jun 26, 2007
Messages
851
I cant get a correct result in my query. I have a field (DelayHours) and I don't want to display anything that's in the range of 9.75 to 14.17. I tried

<"9.75" Or >"14.17"

As my criteria and I still get the results including numbers in that range. The only thing that works but does me no good in a range of numbers is...

Not In ("9.75", "9.83", "14.17")


But that only blocks those numbers. Thoughts?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:55
Joined
Oct 29, 2018
Messages
21,360
Try using AND vice OR.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:55
Joined
May 7, 2009
Messages
19,175
Not (Between 9.75 And 14.17)
 

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:55
Joined
Jan 20, 2009
Messages
12,849
They are numbers and should not be processed as text.

Any comparison must be a complete expression.
Code:
WHERE DelayHours < 9.75 OR DelayHours > 14.17

This is another expression that would do it.
Code:
WHERE NOT DelayHours BETWEEN 9.75 AND 14.17
 
Last edited:

Galaxiom

Super Moderator
Staff member
Local time
Tomorrow, 02:55
Joined
Jan 20, 2009
Messages
12,849
Also beware of performing any arithmetic or comparisons on floating point numbers. The small errors representing floating point in binary can cause unexpected results.

For example, the answer to the following expression can be quite surprising. (Type it in the immediate window of VBA and press Enter)
Code:
? 0.7 * 90 = 63
 

Users who are viewing this thread

Top Bottom