Focal Point
[SOLVED] timestamp arithmetic.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4331034542

September 05, 2007, 10:24 AM
Jason K.
[SOLVED] timestamp arithmetic.
I have a master file with two fields
FIELDNAME=CLOCK_IN, ALIAS=CLOCK_IN, USAGE=HYYMDm, ACTUAL=HYYMDm,
MISSING=ON, $

FIELDNAME=CLOCK_OUT, ALIAS=CLOCK_OUT, USAGE=HYYMDm, ACTUAL=HYYMDm,
MISSING=ON, $

both are DB2 Timestamp fields. Is there any way to subtract clock_out - clock_in? When I create a compute just like that, I end up with a can't do math on an alphanumeric error.

Searching IBI's website shows a lot of how to convert data into timestamps, but not how to do arithmetic with them.

Thanks!

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


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
September 05, 2007, 10:47 AM
Prarie
Well hopefully there is an easier way.

http://techsupport.informationbuilders.com/sps/12162011.html


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
Jason, give the HDIFF function a try:
quote:
Syntax: How to Find the Number of Units Between Two Date-Time Values
HDIFF(value1, value2, 'component', outfield) where:

value1 - Date-time - Is the end date-time value, the name of a date-time field that contains the value, or an expression that returns the value.

value2 - Date-time - Is the start date-time value, the name of a date-time field that contains the value, or an expression that returns the value.

component - Alphanumeric - Is the name of the component to be used in the calculation enclosed in single quotation marks. If the component is a week, the WEEKFIRST parameter setting is used in the calculation.

outfield - Floating-point double-precision -Is the field that contains the result, or the format of the output value enclosed in single quotation marks. The format must be floating-point double-precision.

E.G.:
CONF_DIFF/D12 = HDIFF(DT_ADLSCONF, DT_ADLSINIT, 'SECOND', CONF_DIFF);
DL_AGE/D8     = HDIFF(EFFECTIVEDATE,DATEOFBIRTH,'YEAR','D8');
MINUTES/D20   = HDIFF(COMPLETION_DATE,CREATION_DATE,'MINUTE','D20') ;

-SET &MILSEC  = HDIFF(&ENDTIME, &BEGTIME, 'MILLISECOND', D12.2);



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
great info!
thanks!


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
Is there a singe function to show the results of HDIFF or DATEDIF in a format such as DD HH:MM?

as follws:
A) (8/1/2008 4:58:00 PM) - (Aug 29, 08 2:08 PM) = 0 01:26 ... 0 days, 1 hour 26 minutes

B) (8/1/2008 4:58:00 PM) - (8/5/2008 6:24 PM) = 4 01:26 ... 4 days, 1 hour 26 minutes

[WF 764] Thanks in advance - Doug




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
Doug,

Look at https://forums.informationbuilders.com/eve/forums/a/tpc/...1057331/m/6011088892