Sum of hours during week

  • Thread starter Thread starter gr
  • Start date Start date
G

gr

Hello,
I have a query which returns a name field, date field, and
sum of working hours from 4 different areas. (the query is
based on other queries)
Now what I want is to calculate the sum of hours by week.
For example the user will give His name and a date (maybe
Today) how can I calculate the sum of hours in the week of
the given date? I know datepart function do something
similar.. but can't figure how. also I don't know if this
calculation should be done in the query of in an unbound
txt box in a form.

Any help will be appreciated.
 
You need a where clause in your query. Generically that would look like the following.

SELECT SomeName, Sum(HoursWorked)
FROM YourSource
WHERE WorkDate Between
DateAdd("d",1-WeekDay([Date in Week]),[Date in Week]) And
DateAdd("d",7-WeekDay([Date in Week]),[Date in Week])
AND SomeName = [Input Name]
GROUP BY SomeName
 
Back
Top