Subtract DATE_AND_TIME from DATE_AND_TIME
SUB_DT_DT subtracts a value of the data type DATE_AND_TIME from another DATE_AND_TIME value. The result is stored in the output variable of the data type TIME.
Input
1st input: minuend
2nd input: subtrahend
Output
Result
The TIME result is only valid if the difference between the minuend and subtrahend is smaller than or equal to the maximum TIME duration allowed. Otherwise an overflow of the TIME result variable occurs and the CARRY flag is set.
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
DT_value1: DATE_AND_TIME:=DT#2011-12-24-18:29:59;
DT_value2: DATE_AND_TIME:=DT#2011-12-06-05:21:28;
TIME_result: TIME:=T#0s;
END_VAR
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,DT_value1,16,1,18,3,);
B(B_VARIN,,DT_value2,16,2,18,4,);
B(B_VAROUT,,TIME_result,26,1,28,3,);
B(B_F,SUB_DT_DT!,Instance,18,1,25,4,,?D?D?C);
L(1,0,1,5);
L(25,2,26,2);
END_NETWORK_BODY
END_NET_WORK
END_BODY
TIME_result := SUB_DT_DT(DT_value1, DT_value2);