Can you be more specific? Where do I add this new field? How do I group it? What do I write to show me the sum of sales on each day? Anything else I need to do to make it work?
Main Topics
Browse All TopicsI have a table which contains sales data called "apps"
I'd like to generate a report which will show me the total sales between two dates on each day of the week. In other words it'll show total sales completed on Sunday between 1/1/2009 and 3/16/2009, then total sales completed on Monday between the same dates, etc (for each day of the week).
Any ideas? I can pass the dates from a form, that's not the issue. The question is how to structure the report so that it gives me a total for each day of the week.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
So long as you two dates are never more than a week apart, you need a small table tblWeekdays, with the integer field Weekday containing the values 0 thru 6.
In you table Sales in which you have recorded sales by day, assuming the table looks something like:
tblSales
====
SalesID - pk
SalesDate - datetime
SalesPerson - fk from tblSalesPersons
CustomerID - fk from tblCustomers
SalesItem - fk - from tbl
Amount - Currency
Now you create a query:
PARAMETERS [EnterStartDate] DateTime;
SELECT DateAdd("d", b.WeekDay, a.SalesDate) AS DateInWeek, Sum(a.Amount) FROM tblSales a, tblWeekDays b WHERE DateAdd("d", b.WeekDay, a.SalesDate) >= [EnterStartDate] GROUP BY a.SalesDate;
This should generate a recordset of all the sales made from the date entered to one week later.
I took 'for each day of the week' to mean you were only interested in a week's worth of data if you need it for up to a max of x number of days, the tblWeekDays now becomes tblDays containing the interger values 0 thru to x-1. Change the query to:
PARAMETERS [EnterStartDate] DateTime, [EnterEndDate] DateTime;
SELECT DateAdd("d", b.WeekDay, a.SalesDate) AS DateOfSale, Sum(a.Amount) AS DailySum
FROM tblSales a, tblWeekDays b
WHERE DateAdd("d", b.WeekDay, a.SalesDate)
BETWEEN [EnterStartDate] AND [EnterEndDate]
GROUP BY a.SalesDate;
Sorry, lets just call it tblNums, containing the integer field Num:
PARAMETERS [EnterStartDate] DateTime, [EnterEndDate] DateTime;
SELECT DateAdd("d", b.Num, a.SalesDate) AS DateOfSale, Sum(a.Amount) AS DailySum
FROM tblSales a, tblNums b
WHERE DateAdd("d", b.Num, a.SalesDate)
BETWEEN [EnterStartDate] AND [EnterEndDate]
GROUP BY DateAdd("d", b.Num, a.SalesDate);
You never said your sales date included the time. New query:
PARAMETERS [EnterStartDate] DateTime, [EnterEndDate] DateTime;
SELECT DateValue(DateAdd("d", b.Num, a.SalesDate)) AS DateOfSale, Sum(a.Amount) AS DailySum
FROM tblSales a, tblNums b
WHERE DateValue(DateAdd("d", b.Num, a.SalesDate))
BETWEEN [EnterStartDate] AND [EnterEndDate]+1
GROUP BY DateValue(DateAdd("d", b.Num, a.SalesDate));
Sorry, I must be doing something wrong. Here is a partial result again.
DateOfSale DailySum
5/21/2009 147
5/22/2009 151
5/23/2009 151
5/24/2009 151
5/25/2009 151
5/26/2009 118
5/27/2009 101
5/28/2009 57
5/29/2009 53
These numbers aren't accurately representing the actual sales either for some reason. Here are actual numbers for those dates:
5/21/2009 45
5/22/2009 4
5/23/2009 0
5/24/2009 0
5/25/2009 18
5/26/2009 2
5/27/2009 25
5/28/2009 1
5/29/2009 0
When I tried your code snippet, I received the following error: "You tried to execute a query that does not include the speciied expression 'Weekday(a.TimeIn)' as part of an agregate function.
The closest I've come to the actual result I'm looking for is the last snippet I posted above, but for some reason it's pulling the wrong data. The results are nowhere near accurate.
Business Accounts
Answer for Membership
by: peter57rPosted on 2009-09-25 at 10:30:44ID: 25425134
In the query for your report add a column that is: field)
DayOfWeek:weekday(yourdate
You can then group your report on this field.