Work hours in a month period
How can i work out the work hours in a month period where the work hours are specified as Monday to Friday (8 hours each day), Saturday (6 Hours) and Sunday is (0).
Is this achievable in reporting services or in management studio ?
Your inputs will be much appreciated.
Many thanks
Lummzy
October 30th, 2012 2:23pm
Hi There
Thanks for your posting. Did you try this link? I think that would help you
http://sql.dzone.com/news/get-business-days-and-working-
Many Thanks
Syed Qazafi Anjum
Please click "Mark as Answer" if this resolves your problem or "Vote as Helpful" if you find it helpful
Free Windows Admin Tool Kit Click here and download it now
October 30th, 2012 10:59pm
Hi Lummzy,
To achieve your goal, you can use the following custom code in your report:
Public Function TotalHours(d1 As DateTime, d2 As DateTime) As Integer
Dim day As DateTime = d1
Dim Sats As Integer = 0
Dim others As Integer = 0
Dim hours As Integer = 0
While day <= d2
If day.DayOfWeek = DayOfWeek.Saturday
Then Sats += 1End
If day = day.AddDays(1)
End While
others = (d2 - d1).Days - Satshours = others * 8 + Sats * 6
Return hours
End Function
Regards,
Mike YinMike Yin
TechNet Community Support
November 1st, 2012 6:32am
The solution available in the link above is not intuitive enough.
I want to be able to calculate the work hours between tow parameter dates in SSRS 2008
Something that the expression looks like this =Code.getBusinesshours(Parameters!StartDate.Value,Parameters!EndDate.Value)
The working hours for the week are not 9-17.00 but something like Mon - Friday 6.00-16.00 Sat 11.00-19.00
and Sunday is Nil.
I wonder if this possibleLummzy
Free Windows Admin Tool Kit Click here and download it now
November 3rd, 2012 6:54am
Hi Lummzy,
To achieve your goal, you can use the following custom code in your report:
Public Function TotalHours(d1 As DateTime, d2 As DateTime) As Integer
Dim day As DateTime = d1
Dim Sats As Integer = 0
Dim others As Integer = 0
Dim hours As Integer = 0
While day <= d2
If day.DayOfWeek = DayOfWeek.Saturday
Then Sats += 1End
If day = day.AddDays(1)
End While
others = (d2 - d1).Days - Satshours = others * 8 + Sats * 6
Return hours
End Function
Regards,
Mike YinMike Yin
TechNet Community Support
November 4th, 2012 4:25am
This is brilliant Mike. Thanks a millLummzy
Free Windows Admin Tool Kit Click here and download it now
November 11th, 2012 9:33am