Focal Point
[SOLVED] Calculate Business Hrs Between 2 Dates (8 am -5 pm -Exclude Wkends/Holidays)

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/1157010786

June 19, 2017, 10:58 AM
Leonel
[SOLVED] Calculate Business Hrs Between 2 Dates (8 am -5 pm -Exclude Wkends/Holidays)
We are currently using Developer Studio 8.1.05 and we are using a Business & Holiday File to only count Business Days Elapsed between two dates. The Challenge is to calculate Time Elapsed for Business Hours only.

Example 1: Time-In 06/19/2017 08:00 a.m.
Time-Out 06/26/2017 10:00 a.m.
We count 9 hours per Business day, so 5 days from 8 a.m. = 9*5 = 45 business hours, then we count 2 hours for Monday 06/26/2017 from 8 a.m. to 10 a.m.
Final Answer should be in Minutes, but for simplicity I will calculate this example as hours:
Final Answer = 45 hours + 2 = 47 hours elapsed.

Example 2: Time-In 06/19/2017 04:00 p.m.
Time-Out 06/21/2017 07:00 p.m.
We count 1 hour for first day between 4 p.m. and 5 p.m.
We then count 9 hours for Tuesday 06/20/2017.
We then count 9 hours for Wednesday 06/21/2017.
Then we count 1 hour for anything after 5 p.m. or before 8 a.m.; thus we would count 1 hour for the 7 p.m.
Final Answer = 1 hour + 18 hours + 1 = 20 hours.


Thanks in advance for your time and support.

Leo Sanchez

This message has been edited. Last edited by: Tamra,


WebFOCUS 8

Windows, All Outputs
June 19, 2017, 12:07 PM
MartinY
Write down your rules based on your calendar (which you seems to already have. Such as between 8am and 5pm then do... Before 8am and after 5pm do...).
Convert them to logical test.
Perform proper Focus coding.
Apply calculation.

We can't unfortunately do the job for you.

If you then have specific question on how to use a Focus function per example, we'll then be glad to help you.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
June 19, 2017, 03:52 PM
jcannavo
As MartinY has pointed out, you seem to have the logic and rules figured out. From there it's going to be trial and error using date functions to try and come up with your solution, here's a link to some helpful date/time tips: https://www.informationbuilder...elopers/AllAboutDate. Using that, the help docs, and searching this forum you should be able to get something going.

Me personally I would rather create a function in the database (in our case SQL Server) that would do this sort of calculation and pass that calculated value to WF.

Good luck!


JC
WebFOCUS Dev Studio / App Studio
8.2.01
Windows 7