By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

Access date/time range query

P: n/a
I need to query an Access database via VB and get a count of all the
calls where the start time is between a 2 certain days/times.

For example, all the calls that occurred from Saturday @ 8am to Monday
@ 8am. It needs to be for saturdays - mondays, not just a certain
weekend. Anyone have any clues how to do this?

I have the weekday part down, I am just stumped on how to handle the
time range.
SELECT COUNT(call_id) FROM calls WHERE (weekday(start) >= 7 OR
weekday(start) <=2)

I am not sure how to tie the time range in.

I would appreciate any feedback. Thanks!

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Try:
WHERE WeekDay(DateAdd("h", -8, [start])) IN (7,1,2)

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kristen" <kw*****@synergysw.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I need to query an Access database via VB and get a count of all the
calls where the start time is between a 2 certain days/times.

For example, all the calls that occurred from Saturday @ 8am to Monday
@ 8am. It needs to be for saturdays - mondays, not just a certain
weekend. Anyone have any clues how to do this?

I have the weekday part down, I am just stumped on how to handle the
time range.
SELECT COUNT(call_id) FROM calls WHERE (weekday(start) >= 7 OR
weekday(start) <=2)

I am not sure how to tie the time range in.

I would appreciate any feedback. Thanks!

Nov 13 '05 #2

P: n/a
That worked! Thanks. But I am allowing my software users to inut their
own weekdays & times. So I'm still confused about what to do if they
put in different times.

Like say they choose Saturday 10am - Monday 7am?

Thanks!

Nov 13 '05 #3

P: n/a
Hi Kristen

You will need to use a combination of Weekday() and TimeValue(), e.g.:

(Weekday([start]) = 7) AND TimeValue([Start]) > #10:00:00#) OR
(Weekday(...

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Kristen" <kw*****@synergysw.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
That worked! Thanks. But I am allowing my software users to inut their
own weekdays & times. So I'm still confused about what to do if they
put in different times.

Like say they choose Saturday 10am - Monday 7am?

Thanks!

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.