我已经尝试了一些代码来解决您的问题,并且我认为它按预期工作。
我使用的代码:
-* IGNORE THESE LINES, ONLY FOR DATA SAMPLING
FILEDEF ORDERS DISK orders.ftm (APPEND
-RUN
-*
EX -LINES 6 EDAPUT MASTER,ORDERS,CV,FILE
FILENAME =ORDERS, SUFFIX=FIX
SEGNAME=ORDERS, SEGTYPE=S0, $
FIELD=ORDER_COD_PROD, ALIAS=ORDER_COD_PROD, USAGE=A21 ,ACTUAL=A1 ,$
FIELD=ORDER_DELIVERY, ALIAS=ORDER_DELIVERY, USAGE=HYYMDS,ACTUAL=A30 ,$
FIELD=ORDER_TRACKING, ALIAS=ORDER_TRACKING, USAGE=HYYMDS,ACTUAL=A30 ,$
-*
-WRITE ORDERS 12020/11/20 11:20 2020/11/20 12:45
-WRITE ORDERS 22020/11/20 11:40 2020/11/20 12:45
-WRITE ORDERS 32020/11/20 11:50 2020/11/20 12:45
-WRITE ORDERS 42020/11/20 11:55 2020/11/20 12:45
-WRITE ORDERS 52020/11/20 12:00 2020/11/20 12:45
-*
DEFINE FILE ORDERS
HOW_LATE/D12.2 = HDIFF(ORDER_TRACKING, ORDER_DELIVERY, 'MINUTE', 'D12.2');
DEC_LATE/A10 = IF HOW_LATE GE 60 THEN 'Late' ELSE 'Early';
END
-RUN
-*
TABLE FILE ORDERS
PRINT
ORDER_COD_PROD AS 'ID'
ORDER_DELIVERY AS 'Day/Time Compromised'
ORDER_TRACKING AS 'Day/Time Now'
HOW_LATE AS 'Late (Minutes)'
DEC_LATE AS 'Late (Literal)'
END
-RUN
结果是:
PÁG 1
ID Day/Time Compromised Day/Time Now Late (Minutes) Late (Literal)
1 2020/11/20 11:20:00 2020/11/20 12:45:00 85,00 Late
2 2020/11/20 11:40:00 2020/11/20 12:45:00 65,00 Late
3 2020/11/20 11:50:00 2020/11/20 12:45:00 55,00 Early
4 2020/11/20 11:55:00 2020/11/20 12:45:00 50,00 Early
5 2020/11/20 12:00:00 2020/11/20 12:45:00 45,00 Early
这是虚构的数据,但您可以看到我创建了一个包含多个字段的文件,一个包含产品代码,另一个包含产品必须以时间戳格式交付的时间,最后,另一个包含代表“时刻”的字段”的报告。有了这两个时间戳,我们可以使用函数 HDIFF 来计算两个时刻的分钟差,如 Double。通过这种转换,我们可以检查它是否小于 60 分钟 (LT) 或大于或等于 60 (GE)。
问候。