Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 query but only with business work days

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-07-17 : 03:01:52
I have a query

select * from incomingletters where status='new' and datefilecreated<getdate()-3

now I really want this to return all with the new status that datefilecreated is more then 3 days old (but 3 work days monday-friday) - now it's just returning 3 days.

does anyone have any ideas on how I can do this?

cas_o
Posting Yak Master

154 Posts

Posted - 2007-07-17 : 04:31:09
[code]
select * from incomingletters where status='new' and datefilecreated <
case
when
datename(dw, getdate()) = 'Wednesday'
or datename(dw, getdate()) = 'Tuesday'
or datename(dw, getdate()) = 'Monday'
then
getdate()-5
else
getdate()-3
end
[/code]

This is best I can think of off top of my head. I'm sure there's a better way. If I think of it I'll post it.

;-]... Quack Waddle
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-07-17 : 04:50:42
see
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=46753
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=68414


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

aravindt77
Posting Yak Master

120 Posts

Posted - 2007-07-17 : 05:05:22
Could you please explain the last sentence once again
Go to Top of Page
   

- Advertisement -