S7-1200 Programmable controller
System Manual, V4.2, 09/2016, A5E02486680-AK
335
Date, time-of-day, and clock functions
9.1.1
Date and time-of-day instructions
Use the date and time instructions for calendar and time calculations.
● T_CONV converts a value to or from (date and time data types) and (byte, word, and
dword size data types)
● T_ADD adds Time and DTL values: (Time + Time = Time) or (DTL + Time = DTL)
● T_SUB subtracts Time and DTL values: (Time - Time = Time) or (DTL - Time = DTL)
● T_DIFF provides the difference between two DTL values as a Time value: DTL - DTL =
Time
● T_COMBINE combines a Date value and a Time_and_Date value to create a DTL value
For information about the format of DTL and Time data, refer to the section on the Time and
Date data types (Page 128).
Table 9- 1 T_CONV (Convert times and extract) instruction
in:=_variant_in);
out := TIME_TO_DINT(
T_CONV converts a value to or from (date and time data types) and
(byte, word, and dword size data types).
For LAD and FBD boxes: Click "???" and select the source/target data types from the drop-down menu.
2
For SCL: Drag T_CONV from instruction tree and drop into the program editor, then select the source/target data types.
Table 9- 2 Valid data types for T_CONV conversions
TIME (milliseconds) DInt, Int, SInt, UDInt, UInt, USInt, TOD
SCL only: Byte, Word, Dword
DATE (number of days since Jan. 1 1990) DInt, Int, SInt, UDInt, UInt, USInt, DTL
SCL only: Byte, Word, Dword
TOD (milliseconds since midnight- 24:00:00.000) DInt, Int, SInt, UDInt, UInt, USInt, TIME, DTL
SCL only: Byte, Word, Dword