Date and time instructions
301
Part II IEC Instructions
SUB_DT_DT
Subtract date and time from date and time
To add an enable input and enable output to the instruction, select [With EN/ENO] from the
"Instructions" pane (LD, FBD or IL editor). To reuse an instruction select "Recently used" from the
context menu or press <Ctrl>+<Shift>+<v> in the programming window.
PLC types Availability of SUB_DT_DT (see page 1331)
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.
Data type I/O Function
DATE_AND_TIME 1st input minuend
DATE_AND_TIME 2nd input subtrahend
TIME output result
Description
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.
Data types
Example
In this example the function has been programmed in ladder diagram (LD) and structured text (ST).
POU header
All input and output variables used for programming this function have been declared in the POU
header.
LD
ST
When programming with structured text, enter the following:
TIME_result := SUB_DT_DT(DT_value1, DT_value2);