Link to home
Start Free TrialLog in
Avatar of Dov_B
Dov_B

asked on

how do I create a query that will sum the records of the past week in ms access 2003

how do I create a query that will sum the records of the past week in ms access 2003
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

by past week, what does it include, last week monday to Sunday?
SOLUTION
Avatar of Aaron Tomosky
Aaron Tomosky
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dov_B
Dov_B

ASKER

I sum from sunday through thursday
how do I write the sql in msa access so its not hardcoded and does not need to be rewritten each week
for last monday and last friday dates as past week

select sum([FieldName])
from tableName
where [dateField] between Dateadd("d", - 6 - Weekday(Date, 2),date) and dateadd("d",-2-weekday(date,2),Date)
from sunday through thursday, use this

select sum([FieldName])
from tableName
where [dateField] between Dateadd("d", -7 - Weekday(Date, 2),date) and dateadd("d",-3-weekday(date,2),Date)
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dov_B

ASKER

Thanks you have beeen a great help!
when I run the query it asks me to enter parameter value
how can I get it to run without asking me anything?
Avatar of Dov_B

ASKER

actualy I added the brackets and it stopped asking me for a parameter but did not return any records for this week unless I changed my system date to the 15 th
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Dov_B,

upload a copy of the db