Thread: week day query
View Single Post
  #3  
Old February 16th, 2007, 08:07 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default week day query

Create a table named CountNumber with a number field named CountNUM
containing number zero through your maximum date spread.

I use a table named Joel_Allen and field named Sale to extract data. Use
the two queries below. The first list all dates between start and end. The
second select only weekdays and counts them. You could add a holiday table
and use it for additional criteria.

SELECT Joel_Allen.Sale, Joel_Allen.[Start Date], Joel_Allen.[End Date],
DateAdd("d",[CountNUM],[Start Date]) AS [Days Between]
FROM CountNumber, Joel_Allen
WHERE (((DateAdd("d",[CountNUM],[Start Date]))=[End Date]))
ORDER BY Joel_Allen.Sale, DateAdd("d",[CountNUM],[Start Date]);


SELECT [Dates-Weekdays].Sale, [Dates-Weekdays].[Start Date],
[Dates-Weekdays].[End Date], Count([Dates-Weekdays].[Days Between]) AS
[CountOfDays Between]
FROM [Dates-Weekdays]
WHERE (((Weekday([Days Between])) Between 2 And 6))
GROUP BY [Dates-Weekdays].Sale, [Dates-Weekdays].[Start Date],
[Dates-Weekdays].[End Date];

You could add a holiday table and use it for additional criteria.

"Joel Allen" wrote:

Hi,

I'm trying to do a simple calculation of the number of weekdays between two
dates. This what I have in my query, but it's not working. Seems so
simple, but it's not. Anybody have any suggestions? Sorry, kind of slow
with this stuff!

Test: Weekday([Start Date]-[End Date])

Thanks, Joel