Focal Point
[CLOSED] How to find out the different of 2 date time

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

August 29, 2011, 09:36 PM
Kengaun
[CLOSED] How to find out the different of 2 date time
Hi,


How to find out the different of time between 2 date/time eg YYYYMMDD HHMMSS - 20110801 081500 and 20110802 150000 ?

Currently we are running Focus 6.9.4 on OpenVMS Alpha Operating System, Version V6.2-1H3.

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


Focus 6.9.4 on OpenVMS
, All Outputs
August 29, 2011, 09:50 PM
Waz
Please check out the documentation on HDIFF.


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!

August 29, 2011, 10:18 PM
Kengaun
Hi Waz,

Thanks for the information

We are using Focus 6.9.4 on OpenVMS, the function supported by this version ?


Focus 6.9.4 on OpenVMS
, All Outputs
August 29, 2011, 11:32 PM
Waz
It doesn't look promising.

TECHNIQUE: How to change field with P4 format to a date or time format

You can always try it out and see.

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. e.g. seconds minutes, etc
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. In Maintain, you must specify the name of the field.


TABLE FILE VIDEOTR2
PRINT CUSTID TRANSDATE AS 'DATE-TIME' AND COMPUTE
ADD_MONTH/HYYMDS = HADD(TRANSDATE, 'MONTH', 2, 8, 'HYYMDS');
DIFF_DAYS/D12.2 = HDIFF(ADD_MONTH, TRANSDATE, 'DAY', 'D12.2');
WHERE DATE EQ 2000;
END



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!

August 30, 2011, 01:00 AM
Kengaun
Hi Waz

In the link you have provided mentioned to search the document from Knowledge Base

Can you help to advise where/how to access the Knowledge Base ?


Focus 6.9.4 on OpenVMS
, All Outputs
August 30, 2011, 01:39 AM
Waz
There is two things you can do.

1. Use the search facility. ecl

2. Register with Techsupport

If you register, you can put questions to IBI


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!

September 04, 2011, 11:22 PM
Kengaun
Hi Waz,

Using the example provided by you as below and the result of HHDIFF encountered negative value.

Do you have any advise on how to resolve the negative value ?

DEFINE FILE F071TCYA
TSIN/I8 = EDIT(SINDATE);
TSHP/I8 = EDIT(SHPDATE);
TDI/I8 = DAYMD(TSIN,'I8');
TDS/I8 = DAYMD(TSHP,'I8');
DAYD/I8 = TDS-TDI;
-*
BIHH/I2=EDIT(EDIT(SINTIME,'99$$$$'));
BIMM/I2=EDIT(EDIT(SINTIME,'$$99$$'));
BISS/I2=EDIT(EDIT(SINTIME,'$$$$99'));
BSEC/I9=(BIHH * 3600)+(BIMM * 60) + BISS ;
EIHH/I2=EDIT(EDIT(SHPTIME,'99$$$$'));
EIMM/I2=EDIT(EDIT(SHPTIME,'$$99$$'));
EISS/I2=EDIT(EDIT(SHPTIME,'$$$$99'));
ESEC/I9=(EIHH * 3600)+(EIMM * 60) + EISS ;
DIFFSEC/I9=ESEC-BSEC;
-*CONVERT BACK TO HH MM SS
HHDIFF/I5 = DIFFSEC/3600;


Sample data :-
SINDATE SINTIME SHPDATE SHPTIME
20110825 184201 20110904 165257
20110826 070401 20110904 041348

TDI TDS DAYD HHDIFF ESEC BSEC
40779 40789 10 -1 60777 67321
40780 40789 9 -2 15228 25441


Focus 6.9.4 on OpenVMS
, All Outputs
September 05, 2011, 12:10 AM
Waz
HHDIFF comes from DIFFSEC, which comes from the subtraction of BSEC from ESEC

For the first record DIFFSEC is -6544, the next is -10213.

Because you are dividing this by 3600, and putting the result ito an integer, you will get -1 and -2.

Should you be including the dated in this as well ?


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!

September 05, 2011, 01:06 AM
Kengaun
Hi Waz,

Will do TTLD/P5.1 = DAYD + (DIFFSEC/3600)/24


Focus 6.9.4 on OpenVMS
, All Outputs