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] Help, difference between two times?

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Help, difference between two times?
 Login/Join
 
Member
posted
I am trying to find the time difference between two timestamps, I have a Start time, and several fields where I need to calculate the processing time. I need to get down to a minute and second level and maybe milliseconds in the future. I would love if HDIFF supported returning multiple units. I would like to get to a HIS2 format, and make it reusable, for the multiple calculations I need.

Thank you,

Andrew

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


WebFOCUS 7.7.02 Windows, All Outputs
 
Posts: 7 | Registered: April 04, 2011Report This Post
Virtuoso
posted Hide Post
HDIFF can return date-time differences down to the nanosecond level. Simple division math can tranlate the result into whatever level is desired. For example, the code below uses HDIFF to calculate date-time difference in seconds for precision, then translates the result into the number of days (with two decimals) by dividing by the number of seconds in a day (24 * 60 * 60).

TIMEDIFF_DAYS/D6.2S = HDIFF(<end date>,<start_date>,'SECOND','D6.2') / 86400);

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Member
posted Hide Post
I can get to the minute, second, and millisecond level. I just want to be able to get the results to return at a 24:36:52 format, and the ability to reuse the code, as needed. The data I am looking at has a start and end time. However there are other times that could be there, if the process has issues, it could go through several steps prior to the end time. The reporting is a breakdown of these “other” processes. IE:

Process Start Time Duplicate Correction End Time
xyz 22:12:12.03 - - 22:12:14.05

xyz Total Time 00:00:02.03


qrs 22:13:24.12 22:13:30.20 22:13:34.42 22:14:12.17

qrs Total Time 00:00:48:05
qrs Start To Duplicate 00:00:06.08
qrs Duplicate To Correction 00:00:04:22

The data will usually be seconds, and milliseconds. Minutes are possible, but fairly uncommon.


Sorry for the formatting.

This message has been edited. Last edited by: ahulting,
 
Posts: 7 | Registered: April 04, 2011Report This Post
Expert
posted Hide Post
You could write a DEFINE FUNCTION that you call whenever you need the time difference in that format. The complicated calculation to determine the difference in hours:minutes:seconds.milliseconds is written once and you simply call the function passing the two date-time fields.

Look into Creating Reporting Applications > Creating Temporary Fields > Creating Temporary Fields Independent of a Master File


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
Here is some code I use in analysis of deferred jobs, that calc the time between steps in hh:mm:ss format.

.
.
.
DT_NULL/HHIS = HINPUT(14, '00000000000000000', 8, 'HHIS');
DT_DIFF/HHIS = HADD(DT_NULL, 'SECOND',HDIFF(DT_FNSH,DT_STRT,'SECOND','D9'), 8, 'HYYMDS');
.
.
.


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
You've got to be kidding!

And I just finished writing a couple of DEFINE FUNCTIONs!

Using your code for milliseconds:

DT_DIFF2/HHISs = HADD(DT_NULL, 'MILLISECOND',HDIFF(EN_DTTM,ST_DTTM,'MILLISECOND','D9'), 8, 'HYYMDs');


Fantastic job Waz!!!


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
Its great to get a bit of positive feedback, especially after a nice long lunch at the pub.
Big Grin


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
Waz, I'll probably still write a DEFINE FUNCTION for Dialogue Manager use.

Cheers.


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
Frowner


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
Member
posted Hide Post
I was playing with this, and herer is how I get to durration.

 MILLISECOND/I9=HDIFF(FINISH_TIMESTAMP, START_TIMESTAMP, 'MILLISECOND', 'D12.3');
IMINUTE/I2=MILLISECOND / 60000;
ISECOND/P2=(MILLISECOND / 1000) - (IMINUTE * 60);
IMILLISECOND/I5=MILLISECOND - (IMINUTE * 60000);
DURATION/A15=EDIT(IMINUTE) || ':' || EDIT(EDIT(IMILLISECOND),'99') || '.' || EDIT(EDIT(IMILLISECOND),'$$999'); 


WebFOCUS 7.7.02 Windows, All Outputs
 
Posts: 7 | Registered: April 04, 2011Report This Post
Master
posted Hide Post
This recent thread was timely, as I had a requirement similar to the OP.

Here is what I came up with, using the great ideas in this post:
-DEFAULTH &NOPRINT = 'NOPRINT'
APP PREPENDPATH IBISAMP       
-RUN
DEFINE FILE GGSALES
-* Not part of the technique, just need to create date-time fields for testing.  
 DATE_START/HYYMDS  = DT(2005/12/26 05:45:05.000);
 DATE_END/HYYMDS = DT(2006/12/26 15:46:06.000);
END                          
TABLE FILE GGSALES
PRINT SEQ
      DATE_START 
      DATE_END
COMPUTE SC_DIFF/I9  = HDIFF(DATE_END,DATE_START,'SECOND','I9'); &NOPRINT
COMPUTE DAYS/I3L    = SC_DIFF / 86400;                          &NOPRINT
COMPUTE HOURS/I2L   = IMOD(SC_DIFF, 86400, 'I5') / 3600;        &NOPRINT
COMPUTE MINUTES/I2L = IMOD(SC_DIFF,  3600, 'I5') /   60;        &NOPRINT
COMPUTE SECONDS/I2L = IMOD(SC_DIFF,    60, 'I5')       ;        &NOPRINT
COMPUTE OUTPUTC/A12 = EDIT(DAYS) | ' ' | EDIT(HOURS) | ':' | EDIT(MINUTES) | ':' | EDIT(SECONDS); 
          AS 'Difference in Days Hours Min Secs'
-*
IF RECORDLIMIT EQ 1
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
 INCLUDE=ENDEFLT.STY,$
ENDSTYLE
END





Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
 
Posts: 822 | Registered: April 23, 2003Report This Post
Master
posted Hide Post
Why the amper NOPRINT ??


WebFOCUS 7.7.05 Windows, Linux, DB2, IBM Lotus Notes, Firebird, Lotus Symphony/OpenOffice. Outputs PDF, Excel 2007 (for OpenOffice integration), WP
 
Posts: 674 | Location: Guelph, Ontario, Canada ... In Focus since 1985 | Registered: September 28, 2010Report This Post
Guru
posted Hide Post
&NOPRINT might be handy for testing.

HTH


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
 
Posts: 252 | Location: USA | Registered: April 15, 2003Report This Post
Virtuoso
posted Hide Post
This seems to work correctly around DST changes as well. Nice!


WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010
: Member of User Group Benelux :
 
Posts: 1669 | Location: Enschede, Netherlands | Registered: August 12, 2010Report This Post
Expert
posted Hide Post
Pardon my reply to the question:
quote:
Why the amper NOPRINT ??
Just to control the PRINTing or NOPRINTing of the associated feld based on the "-DEFAULTH &NOPRINT = 'NOPRINT'"
 
Posts: 3132 | Location: Tennessee, Nashville area | Registered: February 23, 2005Report 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] Help, difference between two times?

Copyright © 1996-2020 Information Builders