Link to home
Start Free TrialLog in
Avatar of hellblazeruk
hellblazeruk

asked on

Microsoft Access Query

Hi,

I am looking for help with an access query,
I am looking for the date parameter to be the system date -1 day

My current query is

SELECT Products.ItemNumber, Products.ItemName, Sum(SalesHistory.Revenue) AS SumOfRevenue, Sum(SalesHistory.NumberSold) AS SumOfNumberSold
FROM Products INNER JOIN SalesHistory ON Products.ItemNumber = SalesHistory.ItemNumber
WHERE (((SalesHistory.ImportDate)=Date()))
GROUP BY Products.ItemNumber, Products.ItemName
ORDER BY Sum(SalesHistory.NumberSold) DESC;
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

IF ImportDate is purely a date field (no time component) then

WHERE (((SalesHistory.ImportDate)=Date() -1))

Otherwise, you will need something like:

WHERE (SalesHistory.ImportDate>=Date() -1)
AND (SalesHistory.ImportDate < Date())
In T_SQL you would use:

DATEADD(day,-1,GETDATE())

For JET (Access):

Dateadd("d",-1,Date())
ASKER CERTIFIED SOLUTION
Avatar of Steve
Steve
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hellblazeruk
hellblazeruk

ASKER

Thank you.