By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,842 Members | 2,154 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,842 IT Pros & Developers. It's quick & easy.

Retrieve records from 30 Days Prior

P: 58
Hello Friends
I am making a query to retrieve Data 30 days before from Current Date. Here is the query but it is not working.

Expand|Select|Wrap|Line Numbers
  1. SELECT DM.ClassName, DM.SizeName, DM.TDate, DM.FAS, DM.FM
  2. FROM DM
  3. WHERE (((DM.TDate)=Date()-30))
  4. ORDER BY DM.ClassName, DM.TDate;
can any one help me plz.
thanks
irsmalik
Dec 31 '18 #1
Share this Question
Share on Google+
2 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,158
Irsmalik,

I’ve moved your post to a new thread, as it really should be a new discussion.

Based upon your query, it should work. However, I noticed that you are sorting your results by the TDate, which implies that you have multiple dates in your results. However, if you do not have any ClassName that fall on exactly TDate - 30, then you will get no results.

Perhaps your Criteria expression should be:

Expand|Select|Wrap|Line Numbers
  1. WHERE DM.TDate >= Date()-30
This would return all records from within the past 30 days.

However, you do not describe how your query “is not working” so this is just a guess.

Hope this hepps.
Dec 31 '18 #2

NeoPa
Expert Mod 15k+
P: 31,306
I agree with Twinny. Do you really mean you want those records from one particular day only? That day being thirty days before the current date?

If not then you need to clarify your thinking before designing your code. <= or >= can be used depending on what it is you actually want.

Further, please never just post that something isn't working. If you don't tell us what the problem is then how are we supposed to help you? Tell us what does happen and what is different from what you expect to happen. If an error is displayed then share that with us.

We like to help but you make that more difficult than it needs to be by withholding information that it is obvious we will need. After ten years why are we still at this very basic stage? What is stopping you from learning the most basic concepts of asking questions properly? It's not for lack of being told many, many times before.

I know English isn't your first language, but these problems are nothing to do with translation. They are missing information you've been told time and again is necessary in order for others to help you.
Jan 2 '19 #3

Post your reply

Sign in to post your reply or Sign up for a free account.