Dates without weekends

D

dwaynesworld

I have a query which lists the total elasped days between the start date and
the end date and the number of vacation hours that an employee has taken.
What I would like is to exclude weekend hours from the total hours field.
Here is the query:

SELECT tblEmployeeTimeOff2.Instructor, Sum(tblEmployeeTimeOff2.[Hours
Taken]) AS [SumOfHours Taken],
DateDiff("d",([forms]![DevelopmentParamForm]![StartDate]),([forms]![DevelopmentParamForm]![EndDate])) AS TotalDays
FROM tblEmployeeTimeOff2
WHERE
(((tblEmployeeTimeOff2.Instructor)=[forms]![DevelopmentParamForm]![NameSelect])
AND ((tblEmployeeTimeOff2.Date) Between
[forms]![DevelopmentParamForm]![StartDate] And
[forms]![DevelopmentParamForm]![EndDate]))
GROUP BY tblEmployeeTimeOff2.Instructor,
DateDiff("d",([forms]![DevelopmentParamForm]![StartDate]),([forms]![DevelopmentParamForm]![EndDate]));

Any help is greatly appreciated
 
M

Michael Gramelspacher

I have a query which lists the total elasped days between the start date and
the end date and the number of vacation hours that an employee has taken.
What I would like is to exclude weekend hours from the total hours field.
Here is the query:

SELECT tblEmployeeTimeOff2.Instructor, Sum(tblEmployeeTimeOff2.[Hours
Taken]) AS [SumOfHours Taken],
DateDiff("d",([forms]![DevelopmentParamForm]![StartDate]),([forms]![DevelopmentParamForm]![EndDate])) AS TotalDays
FROM tblEmployeeTimeOff2
WHERE
(((tblEmployeeTimeOff2.Instructor)=[forms]![DevelopmentParamForm]![NameSelect])
AND ((tblEmployeeTimeOff2.Date) Between
[forms]![DevelopmentParamForm]![StartDate] And
[forms]![DevelopmentParamForm]![EndDate]))
GROUP BY tblEmployeeTimeOff2.Instructor,
DateDiff("d",([forms]![DevelopmentParamForm]![StartDate]),([forms]![DevelopmentParamForm]![EndDate]));

Any help is greatly appreciated

I am not clear on what you want, but maybe:

SELECT T.Instructor,
SUM(T.[Hours Taken]) AS [SumOfHours Taken],
DATEDIFF("d",([forms]![DevelopmentParamForm]![StartDate]),
([forms]![DevelopmentParamForm]![EndDate])) AS TotalDays
FROM (SELECT * FROM tblEmployeeTimeOff2
WHERE Datepart("w",tblEmployeeTimeOff2.[Date]) NOT IN (1,7)) AS T
WHERE (((T.Instructor) = [forms]![DevelopmentParamForm]![NameSelect])
AND ((T.DATE) BETWEEN [forms]![DevelopmentParamForm]![StartDate]
AND [forms]![DevelopmentParamForm]![EndDate]))
GROUP BY T.Instructor,DATEDIFF("d",([forms]![DevelopmentParamForm]![StartDate]),
([forms]![DevelopmentParamForm]![EndDate]));
 

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

Top