June 8, 2016 at 4:40 pm
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 datetime
set @startdate = '1/1/2016'
set @enddate = 1/30/206'
select datediff(hh, @startdate, @enddate) - (only weekend hours here)
from table1
June 9, 2016 at 2:25 am
this may give you a few ideas
http://www.sqlservercentral.com/Forums/Topic1440451-392-1.aspx
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 9, 2016 at 9:32 am
Just remember that you might want to consider holidays as well. That's only achievable from a holidays or calendar table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply