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

Need help with creating DATE Interval

P: 4
I need to get all the results from my table(opportunities) column called CloseDate. That have a CloseDate falling in any date of the past week including the day I run the query.

I tried this but its not working:

Select Opportunities.*
From Opportunities
Where (Opportunities.Closedate) >=date()-7 AND <=date() ;
Jan 7 '09 #1
Share this Question
Share on Google+
6 Replies


DonRayner
Expert 100+
P: 489
You should be using the DateDiff() function in your where statement.
Jan 7 '09 #2

P: 4
Thanks for the quick response.For some reason thats not working with the other criterias that i am using but it works with the Between Clause.
Jan 7 '09 #3

missinglinq
Expert 2.5K+
P: 3,532
Something like this:
Expand|Select|Wrap|Line Numbers
  1. SELECT Opportunities.*
  2. FROM Opportunities
  3. WHERE (((Opportunities.CloseDate) Between Date()-7 And Date()));
Expand|Select|Wrap|Line Numbers
  1. (Opportunities.Closedate) >=date()-7 AND <=date()
isn't valid syntax in Access VBA, it would have to be

Expand|Select|Wrap|Line Numbers
  1. (Opportunities.Closedate) >=date()-7 AND (Opportunities.Closedate) <=date()
Welcome to Bytes!

Linq ;0)>
Jan 7 '09 #4

P: 4
Thanks!
It works now.
Jan 8 '09 #5

missinglinq
Expert 2.5K+
P: 3,532
Glad we could help!

Linq ;0)>
Jan 8 '09 #6

NeoPa
Expert Mod 15k+
P: 31,186
NB. I would consider making the WHERE clause :
Expand|Select|Wrap|Line Numbers
  1. WHERE (((Opportunities.CloseDate) Between Date()-6 And Date()))
I'm guessing you want to cover a period of a single week rather than 8 days, but I may be misinterpreting the question so you see which is required ;)

Welcome to Bytes!
Jan 8 '09 #7

Post your reply

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