select rs with times from 21:00 till 06:00

M

Mario Krsnic

Hello everybody!
How can I select rs with times criteria. I would like to sort only night
times (21:00 - 06:00). I tried so:
vr1=21:00
vr2=06:00

SELECT * FROM table WHERE timevalue(datum) between (vr1) and (vr2)

This query is too broad - I get daily times too.

And this query gives me no rs:
SELECT * FROM table WHERE timevalue(datum) > (vr1) and
timevalue(datum)<(vr2)
What should I do?
Mario
 
D

Daniel

Have you tried this?:

SELECT * FROM table WHERE timevalue(datum) > (vr1) OR
timevalue(datum)<(vr2)

/Daniel
 
D

Daniel

Have you tried:

SELECT * FROM table WHERE timevalue(datum) > (vr1) OR
timevalue(datum)<(vr2)

/Daniel
 
J

John Spencer (MVP)

I would use TWO sets of criteria. One for 21 to 24 and the other for 00:00 to 06:00

SELECT *
FROM Table
Where (TimeValue(Data) >= #21:00:00# and TimeValue(Data) <= #23:59:59#)
OR (TimeValue(Data) >= #00:00:00# and TimeValue(Data) <= #06:00:00#)

an Alternative query might be the following and it may or may not be quicker or
slower. Only testing would tell you that.

SELECT *
FROM Table
Where (TimeValue(DateAdd("h",3,Data)) <= #09:00:00#
 
M

Mario Krsnic

'Thanks, John,
Mario

John Spencer (MVP) said:
I would use TWO sets of criteria. One for 21 to 24 and the other for 00:00 to 06:00

SELECT *
FROM Table
Where (TimeValue(Data) >= #21:00:00# and TimeValue(Data) <= #23:59:59#)
OR (TimeValue(Data) >= #00:00:00# and TimeValue(Data) <= #06:00:00#)

an Alternative query might be the following and it may or may not be quicker or
slower. Only testing would tell you that.

SELECT *
FROM Table
Where (TimeValue(DateAdd("h",3,Data)) <= #09:00:00#
 
Top