Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sales last month

Status
Not open for further replies.

sillysod

Technical User
Jan 6, 2004
300
GB
SELECT Format([Order Recieved],"mmmm yyyy") AS [Month], Sum([Sales Orders].Value) AS SumOfValue, Count([Sales Orders].[G Number]) AS [CountOfG Number]
FROM [Sales Orders]
GROUP BY Format([Order Recieved],"mmmm yyyy")
HAVING (((Format([Order Recieved],"mmmm yyyy"))=DateAdd("m",-1,Format(Now(),"mmmm yyyy"))));


Hi, im using the above sql query to try and get a total for sales last month and how many sales.


I can get sales THIS month without any probs, but last month just returns blank records

 
Try move the Format() outside the DateAdd() and change the Having to a Where.

SELECT Format([Order Recieved],"mmmm yyyy") AS [Month],
Sum([Sales Orders].Value) AS SumOfValue,
Count([Sales Orders].[G Number]) AS [CountOfG Number]
FROM [Sales Orders]
WHERE Format([Order Recieved],"mmmm yyyy")=Format(DateAdd("m",-1,Date()),"mmmm yyyy");
GROUP BY Format([Order Recieved],"mmmm yyyy");



Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top