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

  • Thread starter Thread starter Mario Krsnic
  • Start date Start date
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
 
Have you tried this?:

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

/Daniel
 
Have you tried:

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

/Daniel
 
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#
 
'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#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top