Siemens Industry Online Support
Siemens AG
Entry type: FAQ Entry ID: 21950154, Entry date: 01/23/2008

How do you convert a "DATE_AND_TIME"-type variable into an "ARRAY OF BYTE" in S7-SCL?

  • Entry
  • Associated product(s)

There is no standard function available for converting "DATE_AND_TIME" into "ARRAY OF BYTE". However, you can use the AT construct for this task. All you need is a special declaration.

arDATIstat  AT dtDATIstat ARRAY[0..7] OF BYTE;

Within the declaration the AT construct creates a view of the variable "arDATIstat" to the variable "dtDATIstat". There is thus no conversion, but two variables of different data types share a common data area.

The current CPU system time is to be read out via the system function SFC1 "READ_CLK" and transferred to a diagnostics repeater via the system function SFC58 "WR_REC". As a result of reading out the time, the system function SFC1 provides a variable of the type "DATE_AND_TIME". The system function SFC58 expects this time as a variable of the type "ARRAY OF BYTE". The attachment "S7_SCL_AT_Funktion_d.zip" contains two S7-SCL sources (sample program with German and English comments).

S7_SCL_AT_Funktion_d.zip ( 1 KB )

Filter, Filtering, Data types of variables, Views of variables

Security information
In order to protect technical infrastructures, systems, machines and networks against cyber threats, it is necessary to implement – and continuously maintain – a holistic, state-of-the-art IT security concept. Siemens’ products and solutions constitute one element of such a concept. For more information about cyber security, please visit