SUB_TOD_TOD - Subtracts one time of day value from another


Returns the difference between two time of day values as an interval.

Informal Syntax:

SUB_TOD_TOD( In1, In2 )

Formal Syntax:

SUB_TOD_TOD( In1:=expression, In2:=expression )


In1TIME_OF_DAYThe first time of day value.
In2TIME_OF_DAYThe second time of day value to subtract from the first.

Return value

The function SUB_TOD_TOD returns an interval, the result of In1 - In2.

If In2 is greater than In1, the returned interval will be negative. The return value will always be in the range: T#-23h59m59s999ms to T#-23h59m59s999ms.


ExampleReturn Value
SUB_TOD_TOD( TOD#12:00:00.000, TOD#13:25:00.000 )T#-1h25m
SUB_TOD_TOD( TOD#12:00:00.000, TOD#11:40:00.000 )T#20m
SUB_TOD_TOD( TOD#12:00:00.000, TOD#12:00:00.000 )T#0

Standards Compliance

Table 30.7b - IEC 61131-3 Second Edition.

Table 35.7b - IEC 61131-3 Third Edition.

Further Information

Date and Time Functions

For other date and time functions.


For the meaning of terms used in Fernhill SCADA.