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
 datediff

Author  Topic 

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-03-27 : 22:49:46
I have this statement:

DATEDIFF(day, pubdate, getdate()) AS no_of_days

is it possible exclude saturdays and sundays?

Thanks

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-03-28 : 00:50:35
where datename(weekday,pubdate) NOT IN('Saturday', 'SUNDAY')

May Be lIke this.......
Thanks.
Go to Top of Page

Nageswar9
Aged Yak Warrior

600 Posts

Posted - 2009-03-28 : 02:11:27
where daepart(dw,pubdate) Not In( 6,7)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-28 : 03:24:02
quote:
Originally posted by Nageswar9

where daepart(dw,pubdate) Not In( 6,7)



the result of this can vary based on setting of datefirst so that 6 & 7 do not always correspond to sat & sun
Go to Top of Page

BankOfficerHere
Posting Yak Master

124 Posts

Posted - 2009-03-29 : 21:02:40
is it possible to put it inside the statement and not in where clause?
Go to Top of Page

ashishashish
Constraint Violating Yak Guru

408 Posts

Posted - 2009-03-30 : 00:20:08
use case statement to do this...
Go to Top of Page
   

- Advertisement -