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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query to retrieve yesterday's date and 4 weeks of that same day 1

Status
Not open for further replies.

henchcliffe

IS-IT--Management
Jun 13, 2001
23
US
Hi,
I am trying to write a query that will retrieve yesterday's date (date()-1) plus the past 4 weeks of that same day.

So if today is wednesday the query will retrieve yesterday (tuesday) and the past 5 tuesdays.

Any ideas?

THANKS!
 
Code:
select somecolumns
  from sometable
 where somedatecolumn in
       ( date()-1
       , date()-8
       , date()-15
       , date()-22
       , date()-29 )

rudy
 
ooooops

that should have said

where date()-somedatecolumn
in (1,8,15,22,29){/b]

sorry
 
where date()-somedatecolumn
in (1,8,15,22,29)


sorry
 
Excellent!
I cant believe I didnt think of this before. I was trying to do something with "DateAdd" but this is much simplier.

THANKS!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top