Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting specific days

Status
Not open for further replies.

Leighton21

Technical User
Dec 17, 2001
83
AU
Hi All,

I have a calendar table which contains daily values i.e

01-01-2008
01-02-2008

Is it possible without a join (or otherwise) to select every 7th day given an input day so for example if a user selected

01-01-2008 the next date would be
01-08-2008 and so on.

Cheers
 
Take a look at DatePart. With this, you could determine what day of the week the date is and use that as your criteria to get all dates that are the same day....

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Sorry...forget the example:

Code:
SELECT
	*
FROM dwSalesHistory
WHERE DATEPART(dw, DeliverDate) = DATEPART(dw, '20080829')

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
if you just wanted every 7th day, you could just use floor(Date)%7=0

the % is a mod function...

--------------------
Procrastinate Now!
 
Oops,

you'll need to cast the date as an int...

where cast(date as int)%7 = 0

--------------------
Procrastinate Now!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top