I am trying to write an if statement with 2 conditions.... one of them being if it has been longer than 60 minutes and the other condition is that it is "late". Example, I am trying to determine when shipments are late over an hour but I don't want it to count when shipments are early, just when they are late. Here is the equation I had originally buts its counting when shipments are greater than 60 minutes early as well:
IF HDIFF ( SHIPMENT_INDIVIDUAL_MOVE_COSTING.LOAD_DATE_FIELDS.SL_LD_DROP_ACTUAL_DATE , SHIPMENT_INDIVIDUAL_MOVE_COSTING.LOAD_DATE_FIELDS.SL_LD_DROP_APPT_START_DATE , 'Minute' , 'D6' ) GT 60 THEN 1 ELSE 0
Any assistance or thoughts are appreciated.... I feel stuck
I've tried some code with your problem, and I think it's working as intended.
The code I've used:
-* 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
The result is:
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
This is fictitious data, but you can see I've created a file with several fields, one with product code, other with the time the product has to be delivered in Timestamp format, and lastly, other with a field that represents the "moment" of the report. With these 2 Timestamp we can use the function HDIFF to find the difference in minutes from both moments, as Double. With this conversion, we can check if it's less than 60 min (LT) or greater or equal than 60 (GE).
Regards.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.