473,385 Members | 2,274 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.

Query help - giving a date range given the start date, thanks!

Hi Group!

I am struggling with a problem of giving a date range given the start
date.

Here is my example, I would need to get all the accounts opened between
each month end and the first 5 days of the next month. For example, in
the table created below, I would need accounts opened between
'5/31/2005' and '6/05/2005'. And my query is not working. Can anyone
help me out? Thanks a lot!

create table a
(person_id int
,account int
,open_date smalldatetime)

insert into a values(1,100001,'5/31/2005')
insert into a values(1,200001,'5/31/2005')
insert into a values(2,100002,'6/02/2005')
insert into a values(3,100003,'6/02/2005')
insert into a values(4,100004,'4/30/2004')
insert into a values(4,200002,'4/30/2004')

--my query--
Select *
From a

Where open_date between '5/31/2005' and ('5/31/2005'+5)

Jul 23 '05 #1
2 1549
Select *
From #a

Where open_date between '5/31/2005' and dateadd(day,5,'5/31/2005')

Jul 23 '05 #2
Thanks, great help!

ji**********@countrywide.com wrote:
Select *
From #a

Where open_date between '5/31/2005' and dateadd(day,5,'5/31/2005')


Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
5
by: Got2Go | last post by:
Hello Group, I have a table that has 3 columns: ID (int), datetime, Value(varchar) ID = ID for the SNMP device datetime = time record was added value = value added for that device. This...
1
by: ED | last post by:
I currently have an ODBC query that hits an Oracle database. I want to bring back records for a given month based on a job completion date in the Oracle database. I would like to have the user...
10
by: Gary Toth via AccessMonster.com | last post by:
I have a query that searches for classes held between a date range: SELECT EMP_NAMES.LNAME, EMP_NAMES.FNAME, TRAINING.CLASS_ATTD, TRAINING.DATE_ATTD FROM EMP_NAMES INNER JOIN TRAINING ON...
2
by: tedhekman | last post by:
Hi there! I am pretty new to Access, have been loving learning it! I have a problem here I can't even begin to figure out. Here is what I need: Given 1 Date and 1 Store, retrieve the following...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
3
by: shorti | last post by:
db2 v 8.2 on AIX 5.3 I will try to explain as brief as I can what it is I need. I am building a function that will be called multiple times where I will need to return x amount of records each...
4
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range...
11
by: lenygold via DBMonster.com | last post by:
Hi everybody! This query is supposed to count consecutive years from the current year without OLAP. Input Table: ID DateCol 1 02/01/2006 1 01/01/2006 1 01/01/2005
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.