Solved

Microsoft Access Query

Posted on 2014-10-30
4
162 Views
Last Modified: 2014-11-04
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;
0
Comment
Question by:hellblazeruk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 48

Expert Comment

by:Dale Fye (Access MVP)
ID: 40412882
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())
0
 
LVL 1

Expert Comment

by:mfwiniberg
ID: 40412883
In T_SQL you would use:

DATEADD(day,-1,GETDATE())

For JET (Access):

Dateadd("d",-1,Date())
0
 
LVL 24

Accepted Solution

by:
Steve earned 500 total points
ID: 40413960
I would tend towards BETWEEN:

WHERE SalesHistory.ImportDate BETWEEN Date()-1 AND Date()
0
 

Author Closing Comment

by:hellblazeruk
ID: 40421999
Thank you.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question