Conversion: DATE, DT, TOD, LDATE, LDT, LTOD
The operators convert a date and time value into the specified data type and return a type-converted value.
The data types DATE
and DT
use the same memory format internally and are stored as DWORD
. The resolution for DATE
is 1 day. The resolution for DT
is 1 second. Both begin at January 1, 1970. TOD
is stored as DWORD
with a resolution of 1 millisecond.
The keywords DT
and TOD
are alternative spellings for the data types DATE_AND_TIME
and TIME_OF_DAY
. However, the latter are not mapped as a type conversion command.
The data types LDATE
and LDT
and LTOD
use the 64-bit memory format LWORD
internally.
Call syntax: DATE/DT/TOD_TO_< target type> ( <operand> )
Call syntax: LDATE/LDT/LTOD_TO_< target type> ( <operand> )
Operand | Data Type | Description |
---|---|---|
Variable or literal |
|
DATE_TO_<type> | DT_TO_<type> | TOD_TO_<type> | Example | Return Value | Description |
---|---|---|---|---|---|
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| DATE_TO_BOOL(D#1970-1-1) DATE_TO_BOOL(D#2019-9-1) DT_TO_BOOL(DT#1970-1-1-0:0:0) DT_TO_BOOL(DT#2019-9-1-12:0:0) TOD_TO_BOOL(TOD#0:0:0) TOD_TO_BOOL(TOD#12:0:0) |
| If and only if the operand value can be interpreted as "0", then the operator returns a |
|
|
| |||
- |
|
| Resolution in seconds (although only the day is displayed) | ||
|
|
| DATE_TO_DINT(D#1970-1-1) DATE_TO_DINT(D#1970-1-2) DATE_TO_DINT(D#2019-9-1) DT_TO_DINT(DT#1970-1-1-0:0:0) DT_TO_DINT(DT#1970-1-1-0:0:1) DT_TO_DINT(DT#2019-9-1-12:0:0.0) TOD_TO_DINT(TOD#0:0:0) TOD_TO_DINT(TOD#12:0:0) |
| |
| - |
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| DATE_TO_STRING(D#1970-1-1) DT_TO_STRING(D#1970-1-1-0:0:1) TOD_TO_STRING(12:0:1) |
| |
|
|
| |||
|
| - | |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| DATE_TO_WSTRING(D#1970-1-1) DT_TO_WSTRING(D#1970-1-1-0:0:1) TOD_TO_WSTRING(12:0:1) |
|
LDATE_TO_<type> | LDT_TO_<type> | LTOD_TO_<type> | Example | Return Value | Description |
---|---|---|---|---|---|
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| Seconds (although only the day is displayed) | ||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
- |
|
| Nanoseconds (although only the day is displayed) | ||
| - |
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
| - | |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
| |||
|
|
|
Converting to a string
The operands of type DATE
, DATE_AND_TIME
, TIME_OF_DAY
, DT
, or TOD
, which are passed to an operator for a data and time conversion, are converted to their constant syntax (literal syntax). The generated string contains the keyword D#
, DT#
or TOD#
and then the size with its data and time unit, as indicated in the IEC 61131-3 standard.
The controller is in online mode in order to monitor the variables.
