Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Exclude weekend hours from datediff() function

$
0
0
Hello,I want to get a total amount of hours for a date range, but I want to exclude any weekend hours from this? So, I want to do it all on one select statement as shown below. I'm stuck on the part of how to get only the weekend hours for the date range so I can subtract it from the datediff function. I have looked online, but nothing works. Any help is appreciated. Thanks.declare @startdate datetime, @enddate datetimeset @startdate = '1/1/2016'set @enddate = 1/30/206'select datediff(hh, @startdate, @enddate) - (only weekend hours here)from table1

Viewing all articles
Browse latest Browse all 3145

Trending Articles