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
 General SQL Server Forums
 New to SQL Server Programming
 Excluding Weekends

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2009-08-21 : 09:34:29
I have this formula, but I need to only have the business days and not Saturday and Sunday. How would I take them out of what I have written here?


DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) as "TATDays",

"DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110))" =

Case
WHEN DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) >='0' and DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) <= '1' THEN 'A: Equal to 1 Day'

WHEN DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) > '1' and DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) <= '3' THEN 'B: Greater than 1 day to 3 Days'
WHEN DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) > '3' and DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) <= '5' THEN 'C: Greater than 3 day to 5 Days'
WHEN DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) > '5' and DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) <= '10' THEN 'D: Greater than 5 day to 10 Days'
WHEN DATEDIFF(day, CONVERT(CHAR(10), clm_rcvd, 110), CONVERT(CHAR(10), clm_dout, 110)) > '10' THEN 'G: Greater than 10 Days'


end,

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-08-21 : 09:39:51
Look here.

http://weblogs.sqlteam.com/brettk/archive/2005/05/12/5139.aspx
Go to Top of Page
   

- Advertisement -