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     [SOLVED] Milliseconds to Minutes and Seconds

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Milliseconds to Minutes and Seconds
 Login/Join
 
Master
posted
Ok, I thought I had it, until I found out that HDIFF is rounding for MINUTE.. The report took 33 seconds to run, but HDIFF is coming back that MINUTE = 1 and SECOND = 33. ???

So when I report the time, I get...

Results
Started On: 2015-10-05 13:12:56.171
Finished On: 2015-10-05 13:13:29.660
Total Report Time: 1m -27s

Code
-SET &NOW = HGETC(8, 'HYYMD-s');
-SET &CHKMIN = (HDIFF(&NOW, &STARTTIME, 'MINUTE', 'D8'));
-SET &CHKSEC = (HDIFF(&NOW, &STARTTIME, 'SECOND', 'D8'));
-SET &CHKSEC = (&CHKSEC-(&CHKMIN*60));

-SET &TIMEDIF  = '&CHKMIN.EVALm &CHKSEC.EVALs';

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



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Master
posted Hide Post
This seems to be working, but this is redonkulous.

-SET &CHKSEC = IF (&CHKSEC-(&CHKMIN*60)) LT 0 THEN (&CHKSEC-((&CHKMIN-1)*60)) ELSE (&CHKSEC-(&CHKMIN*60));



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
This is how I calculate the elapsed time between two Dialogue Manager Date/Time variables. Actually they're two Date and Time pairs of variables, &ST_DATE,&ST_TIME, &EN_DATE,&EN_TIME. This might be overkill...

-*-- Set Report End Date and Time
-SET &EN_DATE = &YYMD;
-SET &EN_TIME = EDIT(HHMMSS('A8'),'99$99$99');

-SET &EN_DATEX = EDIT(&EN_DATE,'9999/99/99');
-SET &EN_TIMEX = EDIT(&EN_TIME,'99:99:99');

-*-- Calculate Report Elapsed Time
-SET &DTTM1 = HINPUT(14, '&ST_DATE.EVAL&ST_TIME.EVAL', 14, 'HYYMDS');
-SET &DTTM2 = HINPUT(14, '&EN_DATE.EVAL&EN_TIME.EVAL', 14, 'HYYMDS');

-SET &ELAPSED_S = HDIFF(&DTTM2, &DTTM1, 'SECOND', 'D12');

-SET &ELAPSED_H  = &ELAPSED_S / 3600;
-SET &ELAPSED_MR = FMOD(&ELAPSED_S, 3600, 'F2');

-SET &ELAPSED_M = &ELAPSED_MR / 60;
-SET &ELAPSED_SR = FMOD(&ELAPSED_MR, 60, 'F2');

-SET &ELAPSED_H  = FPRINT(&ELAPSED_H,  'I4',  'A4');
-SET &ELAPSED_M  = FPRINT(&ELAPSED_M,  'I2L', 'A2');
-SET &ELAPSED_SR = FPRINT(&ELAPSED_SR, 'I2L', 'A2');

-SET &ELAPSED_TIME = &ELAPSED_H || 'h' || (' ' | &ELAPSED_M) || 'm' || (' ' | &ELAPSED_SR) || 's';

-TYPE Program Elapsed Time: &ELAPSED_TIME



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
Master
posted Hide Post
I'm having to do this a lot within a report as I'm timing webservices, so I'm attempting to keep the code down to a minimum.

At the same time though, I'm going to look at FMOD a little closer to see if that is something I can use.

Thanks for the input.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
Another option here is to use a DEFINE FUNCTION.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Gavin,

Check out this post.

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
Master
posted Hide Post
quote:
Check out this post.


Right on.. I attempted to use it, but it looks like I can't run it via console, which is where this will always be ran. I'll play around with it when I get a little more time to make it usable for console.

Thanks.



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
A quick mod to allow alpha input -

DEFINE FUNCTION HTIMEDIFF(ENDTIME/A23, BEGTIME/A23)
  D_TIMEBEG/HYYMDs = HINPUT(23, BEGTIME, 8, 'HYYMDs');
  D_TIMEEND/HYYMDs = HINPUT(23, ENDTIME, 8, 'HYYMDs');
  D_DIFF/D12.2  = HDIFF(D_TIMEEND, D_TIMEBEG, 'MILLISECONDS', 'D12.2');
  D_DAYS/I2L    = INT(D_DIFF / 86400000);
  D_HOURS/I2L   = INT((D_DIFF - (D_DAYS * 86400000)) / 3600000);
  D_MINS/I2L    = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000)) / 60000);
  D_SECS/I2L    = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000) - (D_MINS * 60000)) / 1000);
  D_MSECS/I3L   = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000) - (D_MINS * 60000) - (D_SECS * 1000)));
  HTIMEDIFF/A23 = '        '||EDIT(D_DAYS)||' '|EDIT(D_HOURS)||':'||EDIT(D_MINS)||':'||EDIT(D_SECS)||'.'||EDIT(D_MSECS);
END
-RUN

-SET &Time_Beg = '2015-10-05 13:12:56.171';
-SET &Time_End = '2015-10-05 13:13:29.660';
-SET &Time_Diff = HTIMEDIFF(&Time_End, &Time_Beg);

-? &Time


Good luck.

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
Master
posted Hide Post
quote:
A quick mod to allow alpha input -

DEFINE FUNCTION HTIMEDIFF(ENDTIME/A23, BEGTIME/A23)
D_TIMEBEG/HYYMDs = HINPUT(23, BEGTIME, 8, 'HYYMDs');
D_TIMEEND/HYYMDs = HINPUT(23, ENDTIME, 8, 'HYYMDs');
D_DIFF/D12.2 = HDIFF(D_TIMEEND, D_TIMEBEG, 'MILLISECONDS', 'D12.2');
D_DAYS/I2L = INT(D_DIFF / 86400000);
D_HOURS/I2L = INT((D_DIFF - (D_DAYS * 86400000)) / 3600000);
D_MINS/I2L = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000)) / 60000);
D_SECS/I2L = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000) - (D_MINS * 60000)) / 1000);
D_MSECS/I3L = INT((D_DIFF - (D_DAYS * 86400000) - (D_HOURS * 3600000) - (D_MINS * 60000) - (D_SECS * 1000)));
HTIMEDIFF/A23 = ' '||EDIT(D_DAYS)||' '|EDIT(D_HOURS)||':'||EDIT(D_MINS)||':'||EDIT(D_SECS)||'.'||EDIT(D_MSECS);
END
-RUN

-SET &Time_Beg = '2015-10-05 13:12:56.171';
-SET &Time_End = '2015-10-05 13:13:29.660';
-SET &Time_Diff = HTIMEDIFF(&Time_End, &Time_Beg);

-? &Time


Your alright, no matter what everyone else says about you. :P



- FOCUS Man, just FOCUS!
-----------------------------
Product: WebFOCUS
Version: 8.1.04
Server: Windows 2008 Server
 
Posts: 578 | Registered: October 01, 2014Report This Post
Expert
posted Hide Post
quote:
no matter what everyone else says about you.

We all have our burdens to bear! Wink

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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Milliseconds to Minutes and Seconds

Copyright © 1996-2020 Information Builders