Reference programming 7.2.9.4 TO_STRING conversions Conversions from different type to STRING. Examples in ST: str:=BOOL_TO_STRING(TRUE); (* Result is 'TRUE' *) str :=TIME_TO_STRING(T#12ms); (* Result is 'T#12ms' *) str :=DATE_TO_STRING(D#2002-08-18); (* Result is 'D#2002-08-18' *) str:=TOD_TO_STRING(TOD#14:01:05.123); (* Result is 'TOD#14:01:05.123' *) str:=DT_TO_STRING(DT#1998-02-13-14:20); (* Result is 'DT#1998-02-13-14:20' *) k := LREAL_TO_STRING(); (* Result is '1.4' *) 7.2.9.5 TIME_TO conversions Converting from the variable type TIME to a different type: The time will be stored internally in a DWORD in milliseconds. This value will then be converted.
When you perform a type conversion from a larger to a smaller type, you risk losing some information. For the STRING type variable, the result is a time constant. Examples in ST: str :=TIME_TO_STRING(T#12ms); (* Result is 'T#12ms' *) dw:=TIME_TO_DWORD(T#5m); (* Result is 300000 *) 7.2.9.6 DATE_TO conversions Converting from the variable type DATE to a different type: The date will be stored internally in a DWORD in seconds since Jan. 1, 1970. This value will then be converted. When you perform a type conversion from a larger to a smaller type, you risk losing some information . For STRING type variables, the result is the date constant. Examples in ST:
b :=DATE_TO_BOOL(D#1970-01-01); (* Result is FALSE *) i :=DATE_TO_INT(D#1970-01-15); (* Result is 29952 *) str :=DATE_TO_STRING(D#2002-08-18); (* Result is 'D#2002-08-18' *) vdt:=DATE_TO_DT(D#2002-08-18); (* Result is DT#2002-08-18-00:00 *) udw:=DATE_TO_DWORD(D#2002-08-18); (* Result is 16#3D5EE380 *) 7.2.9.7 TOD_TO conversions Converting from the variable type TIME_OF_DAY to a different type: The time will be stored internally in a DWORD in milliseconds (beginning with 12:00 A.M. for the TIME_OF_DAY variable). This value will then be converted. When you perform a type conversion from a larger to a smaller type, you risk losing some information.
For the STRING type variable, the result is a time constant. Examples in ST: si:=TOD_TO_SINT(TOD#00:00:00.012); (* Result is 12 *) str:=TOD_TO_STRING(TOD#14:01:05.123); (* Result is 'TOD#14:01:05.123' *) TX1200 211 Version: 1.3