Date_to/dt_to conversions, L-force | plc designer – Lenze PLC Designer PLC Designer (R2-x) User Manual

Page 494

Advertising
background image

L-force | PLC Designer

IEC Operators and additional norm extending functions

492

DMS 3.2 EN 02/2011 TD29



9.9.7

DATE_TO/DT_TO Conversions

Converting from the variable type DATE or DATE_AND_TIME 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 IL:

LD D#1970-01-01
DATE_TO_BOOL
ST b

(* Result is FALSE *)

LD D#1970-01-15
DATE_TO_INT
ST i

(* Result is 29952 *)

LD DT#1970-01-15-05:05:05
DT_TO_BYTE
ST byt

(* Result is 129 *)

LD DT#1998-02-13-14:20
DT_TO STRING
ST str

(* Result is 'DT#1998-02-
13-14:20' *)

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 *)

byt :=DT_TO_BYTE(DT#1970-01-15-
05:05:05);

(* Result is 129 *)

str:=DT_TO_STRING(DT#1998-02-13-
14:20);

(* Result is

'DT#1998-02-13-14:20' *)

Advertising