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!

Last 5 business days query

Status
Not open for further replies.

jdgonzalez

Programmer
May 11, 2004
72
US
Hi everyone,

I'm hoping someone can help me out here. I have got a table that holds call tracking information. The table looks like this:

note_id, note_desc, call_date, entry_date

What I'd like to do is to be able to pull the notes for the last 5 business days from today.

Any help would be greatly appreciated.

J.D.
 
this displays the last 5 work days (mon-fri)

Code:
declare @date1 datetime
set @date1 = getdate() - 7
declare @days table(
  [date] smalldatetime,
  day_number tinyint)
  while @date1 <= getdate()
    begin
      insert into @days ([date],day_number) values (@date1, datepart(dw,@date1))
      select @date1 = dateadd(d,1,@date1)
    end

select * from @days
where day_number in (2,3,4,5,6)

should be a good start...

"...we both know I'm training to become a cagefigher...see what happens if you try 'n hit me..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top