473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need help with creating DATE Interval

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
6 1182
DonRayner
489 Expert 256MB
You should be using the DateDiff() function in your where statement.
Jan 7 '09 #2
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
3,532 Expert 2GB
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
Thanks!
It works now.
Jan 8 '09 #5
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Jan 8 '09 #6
NeoPa
32,556 Expert Mod 16PB
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

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

Similar topics

3
by: JA | last post by:
I am trying to pull a time stamp out of a database,looks like this 2004-06-24 10:12:03 . Then I need to substring it so that I can take a difference of 2 times. Basically I making a clock...
8
by: Victor | last post by:
I need a JavaScript timer - I have five events I need to time, that can be triggered by a mouseclick event, or a keypress event. Each event is separated by only one to two seconds. The first...
7
by: meltedown | last post by:
Why doesn't this return anything ? SELECT DATE_SUB('FROM_DAYS(TO_DAYS(2005-09-28 18:04:19))', INTERVAL 6 DAY)
25
by: Bjørn T Johansen | last post by:
I need to write a SQL that calculates the interval between a start time and a stop time. This is the easy part. The problem is that I only have the time part, i.e. no date, so how can I be sure to...
4
by: Brian Coy | last post by:
I have a database that records a part no, a scrap reason, the cost of scrapping that item, and the date. I need to porduce a report that will show up to a weeks worth of data at a time, but I need...
0
by: Lee Harr | last post by:
I wrote a function to return the first date of a given week (and a few related functions) : -- return the first date in the given week CREATE or REPLACE FUNCTION week_start(integer, integer)...
3
by: satish mullapudi | last post by:
Hi, I am using DB v8.2. when I issuing the following stmt.: "select DATE('25.12.2006')-DATE('24.12.2006')from sysibm.sysdummy1" : 1 "select DATE('25.12.2006')-DATE('24.11.2006')from...
2
by: Bill | last post by:
I have a 200 record database that includes a date/time field, AnnivDate, for a wedding anniversary. AnnivDate has nulls and some incorrect year data. I have been creating the Access database...
6
by: _Skare_Krow_ | last post by:
In my script main_date = 2007-01-24 and I'm getting this as my result for the due date 2007 04 06 what am I doing wrong here? Aaron <? $maint_date = date(' Y m d', $maint_date); if...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.