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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limit output to last 3 months

Status
Not open for further replies.

ali32j

Technical User
Joined
Apr 23, 2007
Messages
97
Location
GB
Hi All

I am trying to limit the out put of my query to last 3 months only, tried using the below which i ve modified from showig 12 months, but it still seems to show 3 all 12 months, can anyone help with how i can limit to showing 3 months only

SELECT DISTINCTROW [Actual Sales]*(100/(100+(100*[Growth]))) AS [ActualSales-1], SalesReportTerritory.Month, SalesReportTerritory.[Actual Sales], SalesReportTerritory.[Sales Target], SalesReportTerritory.[Target Percentage], SalesReportTerritory.Growth, SalesReportTerritory.Territory
FROM SalesReportTerritory
WHERE (((SalesReportTerritory.Month)>=DateSerial(Year(Date())-1,Month(Date())+1,0)))
GROUP BY [Actual Sales]*(100/(100+(100*[Growth]))), SalesReportTerritory.Month, SalesReportTerritory.[Actual Sales], SalesReportTerritory.[Sales Target], SalesReportTerritory.[Target Percentage], SalesReportTerritory.Growth, SalesReportTerritory.Territory, Year(SalesReportTerritory.Month)*3+DatePart('m',SalesReportTerritory.Month)-1
ORDER BY SalesReportTerritory.Month;


Thanks

Ali
 
If you field named [Month] is actually a date field, then you should be able to use
Code:
WHERE SalesReportTerritory.Month>=DateAdd("m",-3,Date())

BTW: Month is a poor name for a field since it is the name of a function. It also does little to describe what you are storing in the field.

Duane
Hook'D on Access
MS Access MVP
 
thanks dhookom, noted on the month thing will change to more suitable name
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top