Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to exclude a time period from a query 1

Status
Not open for further replies.

Taecca

Technical User
Jul 20, 2004
59
US
Need to create 2 queries:

Query 1 seems to be working ok:

Select * from temp
where WeekDay not in ("Sat", "Sun") and TimeOfDay between "08:00" and "14:00");

How do I now create another query to select * for the rest of the times? (Weekdays from 14:01 to 07:59 and Saturday/Sunday the entire 24-hour period)

Thank you
 
where WeekDay in ("Sat", "Sun") or not (TimeOfDay between "08:00" and "14:00")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your reply but it did not work.

Basically I need 2 reports: (1 for each period)

Period A is weekdays only from 8 to 14
Period B is every day except weekdays from 8 to 14

The query for period A is okay.

How do I do the query for period B?
 
And this ?
where WeekDay in ("Sat", "Sun") or TimeOfDay not between "08:00" and "14:00"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Weekday cannot be Sat and Sun for the second query.

I need all week long except period A (which is Mon through Fri from 8 am to 14)
 
Some inconsistencies:
Taecca said:
Weekdays from 14:01 to 07:59 and Saturday/Sunday the entire 24-hour period
vs
Taecca said:
Weekday cannot be Sat and Sun for the second query

Perhaps you don't know the difference between 'And' and 'Or' ?
BTW, if your WHERE clause is more complex, you have to play with parenteheses:
where (WeekDay in ("Sat", "Sun") or TimeOfDay not between "08:00" and "14:00") And ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
You are correct. I was getting confused with 'And' and 'Or'

All resolved.

Thank you :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top