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

oxicottin

Learning by pecking away....
Local time
Today, 05:53
Joined
Jun 26, 2007
Messages
666
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, 02:53
Joined
Oct 29, 2018
Messages
14,539
Try using AND vice OR.
 

arnelgp

error reading drive A:
Local time
Today, 17:53
Joined
May 7, 2009
Messages
11,980
Not (Between 9.75 And 14.17)
 

Galaxiom

Super Moderator
Staff member
Local time
Today, 19:53
Joined
Jan 20, 2009
Messages
12,268
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
Today, 19:53
Joined
Jan 20, 2009
Messages
12,268
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