Hi Kali,
Perhaps something like this:
Between Date() And Month(Date()) & "/1/" & Year(Date())-1
Try the following query in the sample Northwind database. You'll need to
create a new query and dismiss the Add Table dialog. Then click on View |
SQL
View, to open the SQL (Structured Query Language) view of the query. Copy
the
SQL statement shown below, and paste it into the SQL View:
TRANSFORM Sum(CCur((1-[Discount])*([Order Details.UnitPrice]*[Quantity])))
AS Sales
SELECT [Lastname] & ", " & [FirstName] AS Employee
FROM (Categories
INNER JOIN Products ON Categories.CategoryID=Products.CategoryID)
INNER JOIN ((Employees
INNER JOIN Orders ON Employees.EmployeeID=Orders.EmployeeID)
INNER JOIN [Order Details] ON Orders.OrderID=[Order Details].OrderID)
ON Products.ProductID=[Order Details].ProductID
WHERE (((Orders.OrderDate) Between Date() And Month(Date()) & "/1/" &
Year(Date())-1))
GROUP BY [Lastname] & ", " & [FirstName]
ORDER BY [Lastname] & ", " & [FirstName],
Right(" " & Right("0" & DatePart("m",[OrderDate]),2) & "/" &
DatePart("yyyy",[OrderDate]),8-(DatePart("yyyy",[OrderDate])-Year(Date())+1))
DESC
PIVOT Right(" " & Right("0" & DatePart("m",[OrderDate]),2) & "/" &
DatePart("yyyy",[OrderDate]),8-(DatePart("yyyy",[OrderDate])-Year(Date())+1));
Of course, you may need to edit some of the records in the Orders table,
so
that the OrderDate field has some records with dates in the past year.
Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
:
Hello
I need to create a database where I need the past 12 months data. For
Jan
2009, I will need Feb-Dec 2008 and Jan 2009. And, so on... I have 3
columns,
year, period, and total. Each period has mulitiple line of totals. What
criteria would I need to retrieve the 12 month data.
I've read some other post, but none with period instead of date format.
thanks in advance.