July 02, 2008, 10:26 AM
TracieDates
I have two dates formatted mm/dd/yyyy hh:mm:ss and I want to determine the number of hours between them. Format is hh.ssssssss. Any thoughts?
July 02, 2008, 11:20 AM
Francis MarianiThe following works with dates formatted yyyy/mm/dd hh:mm:ss:
-SET &ECHO=ALL;
-SET &DTTM1X = '2008/06/01 14:56:11';
-SET &DTTM1Y = EDIT(&DTTM1X,'9999$99$99$99$99$99');
-SET &DTTM1 = HINPUT(14, '&DTTM1Y.EVAL' , 14, 'HYYMDS');
-SET &DTTM2X = '2008/07/02 11:10:38';
-SET &DTTM2Y = EDIT(&DTTM2X,'9999$99$99$99$99$99');
-SET &DTTM2 = HINPUT(14, '&DTTM2Y.EVAL' , 14, 'HYYMDS');
-SET &DIFF_H = HDIFF(&DTTM2, &DTTM1, 'HOUR', D12);
-SET &DIFF_M = HDIFF(&DTTM2, &DTTM1, 'MINUTE', D12);
-SET &DIFF_S = HDIFF(&DTTM2, &DTTM1, 'SECOND', D12);
-TYPE DIFF IN HOURS: &DIFF_H
-TYPE DIFF IN MINUTES: &DIFF_M
-TYPE DIFF IN SECONDS: &DIFF_S
EDIT is used to strip the / and : from the date-time string.
HINPUT is used to convert the date-time string to a date-time formatted value.
HDIFF is used to determine the difference between the two date-time formatted values in different units.
For some reason, I can't get this to work with dates formatted mm/dd/yyyy hh:mm:ss.
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
July 03, 2008, 06:54 AM
TracieThanks, the HDIFF worked beautifully.