Solved

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

Posted on 2011-03-10
10
430 Views
Last Modified: 2012-05-11
how do I create a query that will sum the records of the past week in ms access 2003
0
Comment
Question by:Dov_B
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35104499
by past week, what does it include, last week monday to Sunday?
0
 
LVL 39

Assisted Solution

by:Aaron Tomosky
Aaron Tomosky earned 100 total points
ID: 35104515
Select sum(sumcolumn) from tablename
Where datecolum between('2011-03-01','2011-03-07')
group by sumcolumn
0
 

Author Comment

by:Dov_B
ID: 35104563
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
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35104568
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)
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35104595
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)
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 275 total points
ID: 35104815
you may need to use Date()  instead of 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())
0
 

Author Comment

by:Dov_B
ID: 35104917
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?
0
 

Author Comment

by:Dov_B
ID: 35104936
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
0
 
LVL 50

Assisted Solution

by:Gustav Brock
Gustav Brock earned 125 total points
ID: 35106969
This should do. Find first and last date of this week, subtract one week for both, and subtract further two from the last date (Saturday) to obtain Thursday:

select
  sum([FieldName])
from
  tableName
where
  [dateField] between
    DateAdd("d", 1 - WeekDay(Date(), 1) - 7, Date())
    And
    DateAdd("d", 7 - WeekDay(Date(), 1) - 7 - 2, Date());

/gustav
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35108041
Dov_B,

upload a copy of the db
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question