Focal Point Banner


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.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Calculating Business Time (hours and minutes) between two dates

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Calculating Business Time (hours and minutes) between two dates
 Login/Join
 
Member
posted
I am trying to calculate the "open for business" time between two dates/time stamps (M-F 8-5).

The code I am using follows:

STDAY/YYMD = HDATE(STARTDATE,'YYMD');
EDDAY/YYMD = HDATE(STOPDATE,'YYMD');
BDAYS/D12.2 = DATEDIF(STDAY,EDDAY,'BD') - 1;
BHRS/D12.2 = WDAYS * 9;
SHR/D12.2 = 17 - HPART(STARTDATE,'HOUR','I2');
EHR/D12.2 = HPART(STOPDATE,'HOUR','I2') - 8;
SMIN/D12.2 = HPART(STARTDATE,'MINUTE','I2');
EMIN/D12.2 = HPART(STOPDATE,'MINUTE','I2');
C_SHR/D12.2 = IF SHR GT 9 THEN 9 ELSE SHR;
C_EHR/D12.2 = IF EHR LT 0 THEN 0 ELSE EHR;
BUSINESS_TIME/D12.2 = IF SMIN GT 30 THEN (BHRS + (C_SHR - 1) + C_EHR) ELSE (BHRS + C_SHR + C_EHR);

This calculates almost every instance correctly and rounds the time to the nearest hour. The problem I am having is that for a start time on Sunday and stop time on Monday, this calculation does not work. It returns a negative value for business time.

Any thoughts or alternate methods would be appreciated.

This message has been edited. Last edited by: Kerry,
 
Posts: 2 | Registered: January 11, 2011Report This Post
Member
posted Hide Post
STDAY/YYMD = HDATE(STARTDATE,'YYMD');
EDDAY/YYMD = HDATE(STOPDATE,'YYMD');
BDAYS/D12.2 = DATEDIF(STDAY,EDDAY,'BD') - 1;
*BHRS/D12.2 = BDAYS * 9;
SHR/D12.2 = 17 - HPART(STARTDATE,'HOUR','I2');
EHR/D12.2 = HPART(STOPDATE,'HOUR','I2') - 8;
SMIN/D12.2 = HPART(STARTDATE,'MINUTE','I2');
EMIN/D12.2 = HPART(STOPDATE,'MINUTE','I2');
C_SHR/D12.2 = IF SHR GT 9 THEN 9 ELSE SHR;
C_EHR/D12.2 = IF EHR LT 0 THEN 0 ELSE EHR;
BUSINESS_TIME/D12.2 = IF SMIN GT 30 THEN (BHRS + (C_SHR - 1) + C_EHR) ELSE (BHRS + C_SHR + C_EHR);

*corrected error on this line


7611, windows xp,excel & pdf
 
Posts: 2 | Registered: January 11, 2011Report This Post
Expert
posted Hide Post
Hi John,

This looks a bit confusing to me, is the second post the solution you found?

If you still have questions on this issue, please contact Customer Support Services and open a case for assistance. You may either call at 1-800-736-6130, or access online at InfoResponse.

Cheers,

Kerry


Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
 
Posts: 1948 | Location: New York | Registered: November 16, 2004Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Calculating Business Time (hours and minutes) between two dates

Copyright © 1996-2020 Information Builders