As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
I have a request from a department to count orders offered (available to their division) for over 3hrs Mon-Fri between the hours on 7 and 17:00. Can webfocus count only those hours?
The format is HYYMDs. I have a starting date/time and an ending date/time, but not sure how to count only those hours.
Thanks!This message has been edited. Last edited by: Kerry,
WebFOCUS 768 OS/400 HTML, also quite a few active reports and excel.
I can calculate the difference in time and what day of the week, but how do I only count the hours M-F between 7am and 5pm?
IE. An order is offered Monday at 3pm. It is covered/dispatched Wednesday at 9am. I want to calculate the hours for Monday (3 to 5pm), Tuesday (7am - 5pm), and Wednesday (7 - 9am).
Also, if an order is offered Friday and is accepted, say, Tuesday one week later, I don't want to count the 2 weekends in that time frame.
WebFOCUS 768 OS/400 HTML, also quite a few active reports and excel.
Create a table keyed to date, with a record for each business-day giving its start- and end-of-business-day as DateTime values.
Calculate the processing start- and end-dates of the order; to join to the date table and pull all business dates over the course of the order.
The join allows you to determine the 'start-of-processing' and 'end-of-processing' DateTime values of the order for each date that the interval overlaps (defined using MIN and MAX, or equivalent IF THEN ELSE logic), and the processing time in minutes for each business day based on those two calculated values. Sum that over all the overlapped business days, and you have the order's processing-time metric value.This message has been edited. Last edited by: j.gross,
- Jack Gross WF through 8.1.05
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
There are a few caveats attached to Alan's closed-form approach, depending on the application's requirements. It will not be applicable if ...
... business hours may vary (e.g., early close on eve of a holiday)
... the order arrival time may occur on a non-business day (DATEDIF with 'BD' effectively adjusts its date argument values forward to a business date; and the portion of the arrival date to be counted would deserve to be zero)
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
I also tried another way, and the time was off by a few hours. COMPUTE YRPORT/WRMTDYY=HDATE(TIMEIN, 'YYMD'); COMPUTE YREND/WRMTDYY=HDATE(TIMEOUT2, 'YYMD'); COMPUTE WEEKDAYS/I5=DATEDIF(YRPORT, YREND, 'BD'); COMPUTE DAYS/I5=DATEDIF(YRPORT,YREND, 'D'); COMPUTE DIFF/D12.2=HDIFF(TIMEOUT2, TIMEIN, 'HOUR', DIFF); COMPUTE RESULT/D12.2=DIFF - (WEEKDAYS * 14) - ((DAYS - WEEKDAYS) * 24);
WebFOCUS 768 OS/400 HTML, also quite a few active reports and excel.
When timein and timeout are on the same date (as in the four examples you give), the defined function overcounts in several ways.
You need, roughly speaking:
firstdayhours= if timein is on a business day and time part of timein < 1700 then elapsed hours from max(timein, 0700 on the date of timein) to min(timeout, 1700 on the date of timein) else 0 ;
lastdayhours = if timein and timeout are on different dates and timeout is on a business day and time part of timeout > 0700 then elapsed hours from 0700 on the date of timeout to min(timeout, 1700 on the date of timeout) else 0 ;
hoursbetween = 10 * number of business days strictly between the dates of timein and timeout ;
result = firstdayhours + hoursbetween + lastdayhours;
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
Here's a slightly different approach. Note the absense of IF-THEN-ELSE constructs.
DEFINE FUNCTION HrsElaps(Btime/HYYMDS, Etime/HYYMDS)
-* get date of Begin and End date-time input values
BDATE/YYMD=HDATE(Btime,'YYMD');
EDATE/YYMD=HDATE(Etime,'YYMD');
-* get time, in sec.
BTIME/D12=HTIME(8,Btime,'D12.2')/1000;
ETIME/D12=HTIME(8,Etime,'D12.2')/1000;
-* day number + time as fraction of a day
BTS/D20.4=BDATE + BTIME/(24*60*60);
ETS/D20.4=EDATE + ETIME/(24*60*60);
-* end-points of workday, on beginning and ending dates
B0700/D20.4=BDATE + 07/24; B1700/D20.4=BDATE + 17/24;
E0700/D20.4=EDATE + 07/24; E1700/D20.4=EDATE + 17/24;
-* binary values (0 or 1):
-** Different dates?
DIFF/I1S = BDATE LT EDATE;
-** Are begin and end dates work-days?
BisBD/I1S= BDATE EQ DATEMOV(BDATE,'BD+');
EisBD/I1S= EDATE EQ DATEMOV(EDATE,'BD+');
-* hours to count on beginning day, intermediated work-days, and ending day
-** count hours on Begin date only if it is a Work-day
HOURS1/D12.4S=MAX(0, MIN(B1700,ETS)-MAX(BTS,B0700)) * (BisBD)*24;
-** to determine Work-days between the Begin and End dates, adjust begin and End dates to workday dates
HOURS2/D12.4S=MAX(0, DATEDIF(DATEMOV(BDATE,'BD-'),DATEMOV(EDATE,'BD+'),'BD') -1)*10;
-** count hours on End date only if it is a Work-day and is different from the Begin date
HOURS3/D12.4S=MAX(0, MIN(E1700,ETS)-E0700) * (EisBD*DIFF)*24;
-*
HrsElaps/D12.4S= HOURS1+HOURS2+HOURS3 ;
END
This works even if the assignment arrives or departs on a non-workday.
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005