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.



Read-Only Read-Only Topic
Go
Search
Notify
Tools
Time Calculations
 Login/Join
 
Member
posted
Is there any way in WebFOCUS to operate on timestamps? For example, I would like to take 08:30:30 + 00:15:15, or 08:30:30 - 00:15:15, and other calculations.

Currently, I pull data in from our database in decimal format. So 08:30:00 becomes 8.500, and 08:45:00 becomes 8.750, and 08:45:15 becomes 8.754. Then I can perform the calculations I need to, and use a messy EDIT to convert back to timestamps for display purposes.

COMPUTE SCHEDULEDTIMESTAMP/A8 = EDIT ( INT ( SCHEDULEDHOURS ) , '$$$$$$99' ) || ':' || EDIT ( INT ( ( SCHEDULEDHOURS - INT ( SCHEDULEDHOURS ) ) * 60 ) , '$$$$$$99' ) || ':' || EDIT ( ( ( ( SCHEDULEDHOURS - INT ( SCHEDULEDHOURS ) ) * 60 ) - INT ( ( SCHEDULEDHOURS - INT ( SCHEDULEDHOURS ) ) * 60 ) ) * 60 , '$$$$$$99' ); AS 'Scheduled,Hours'

Any help on making this cleaner is appreciated.

We are using WebFOCUS 7.1.3 in a Managed Reporting environment.
 
Posts: 21 | Registered: September 06, 2006Report This Post
Expert
posted Hide Post
Tom,

I know what you mean, but you could always remove the "messy" code into a FUNCTION and then call it when needed -
DEFINE FUNCTION DECTOTIM(DEC_TIME/D12.5)
HOURS/A2 = EDIT(INT(DEC_TIME),'$$$$$$99');
MINS/A2  = EDIT(INT((DEC_TIME - INT(DEC_TIME))*60),'$$$$$$99');
SECS/A2  = EDIT((((DEC_TIME - INT(DEC_TIME)) * 60) -
            INT((DEC_TIME - INT(DEC_TIME)) * 60)) * 60,'$$$$$$99');
DECTOTIM/A8 = HOURS | ':' | MINS | ':' | SECS;
END
TABLE FILE CAR
SUM COMPUTE SCHEDHOURS/D12.5 = 8.754;
    COMPUTE TIMEOUT/A8 = DECTOTIM(SCHEDHOURS); AS 'Scheduled,Hours'
BY COUNTRY
END
-RUN

Just note that the output from the function is named the same as the function itself (DECTOTIM in this instance).

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Expert
posted Hide Post
I think the cleanest way is to convert the time you want to add/subtract to seconds and then use the HADD function:

HADD(value, 'component', increment, length, outfield)

Example
-SET &CURR_DTTM = &YYMD || EDIT(HHMMSS('A8'),'99$99$99');
DEFINE FILE CAR
CURR_DTTM/HYYMDS WITH CAR = HINPUT(14, '&CURR_DTTM', 8, 'HYYMDS');
SEC_INCR/P4 WITH CAR = (15 * 60) + 15;
END
TABLE FILE CAR
PRINT CURR_DTTM SEC_INCR 
COMPUTE NEXT_DTTM/HYYMDS = HADD(CURR_DTTM , 'SECONDS', SEC_INCR, 8, 'HYYMDS');
WHERE RECORDLIMIT EQ 1
END


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
I think that's the point Francis, one either uses decimal notation to ease the calculations or uses the WF built in functions to perfrom the calculations. Down to a comfort factor I think.

I am sure that we would be inclined to use the internal functions, but for someone new to WF this may be a step too far?

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
Tony A, thanks for the post on how to do custom functions, that has proven to be extremely useful.

Francis, I understand your concept, but I would have to have some of the values in TIME format, and then some in just seconds to perform the calculations like that. Also, I am usually adding up multiple values and doing division, so that solution would not be elegant.
 
Posts: 21 | Registered: September 06, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic


Copyright © 1996-2020 Information Builders