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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

complicated query : Show weekday with time criteria and group 1

Status
Not open for further replies.

hsingh1981

Programmer
Apr 8, 2008
56
GB
Hi all i am trying to do query which shows counts the number of records where the date is > then 01/02/2008 onwards. But show data for only weekdays (monday to friday). With a time range off 08:00 am to 20:00.

eg.

NumberOfRecs DateInserted
6 Feburary
20 March
13 April


Don't know how to filter for weekdays and count them? this is what i got so far

Code:
SELECT tbl_METOBS.METOBSID, tbl_METOBS.TimeAdded, Format([DateAdded],"mmmm") AS DateInserted
FROM tbl_METOBS
WHERE (((tbl_METOBS.DateAdded)>=#2/1/2008#))
ORDER BY tbl_METOBS.DateAdded, tbl_METOBS.TimeAdded;
 
Code:
SELECT Format([DateAdded],"mmmm") AS DateInserted, 
       Count(*) As [Number of Records]

FROM tbl_METOBS

WHERE DateAdded >= #2/1/2008# 
  AND Weekday(DateAdded) BETWEEN 2 And 6
  AND Hour(TimeAdded)    BETWEEN 8 And 20 

GROUP BY Format([DateAdded],"mmmm") 

ORDER BY [DateAdded];
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top