Date and time data types
The DATE, DATE_AND_TIME (DT) and TIME_OF_DAY (TOD) data types are handled internally like a UDINT (32-bit value).
Data type | Lower limit | Upper limit | Storage space | Resolution |
---|---|---|---|---|
DATE | 0 = D#1970-01-01 | 4294967295 = D#2106-02-07 | 32-bit | Seconds, although only the day is displayed. |
DATE_AND_TIME | 0 = DT#1970-1-1-0:0:0 | 4294967295 = DT#2106-02-07-06:28:15 | 32-bit | Seconds |
TIME_OF_DAY | 0 = TOD#0:0:0 | 86399999 = TOD#23:59:59.999 | 32-bit | Milliseconds |
The LDATE, LDATE_AND_TIME (LDT) and LTIME_OF_DAY (LTOD) are handled internally like a ULINT (64-bit).
Data type | Lower limit | Upper limit | Storage space | Resolution |
---|---|---|---|---|
LDATE | 0 = LD#1970-1-1 | 264-1 = LD#2554-7-21 | 64-bit | Nanoseconds, although only the day is displayed. |
LDATE_AND_TIME | 0 = LDT#1970-1-1-0:0:0 | 264-1 = LDT#2554-7-21-23:34:33.709551615 | 64-bit | Nanoseconds |
LTIME_OF_DAY | 0 = LTOD#0:0:0 | 86399999999999 = LTOD#23:59:59.999999999 | 64-bit | Nanoseconds |
Requirements For the data types LDATE, LDATE_AND_TIME (LDT) and LTIME_OF_DAY (LTOD) TwinCAT version 3.1.4026.0 or later is required. |
Samples:
VAR
// Date
dLowerLimit : DATE := DATE#1970-1-1;
dUpperLimit : DATE := DATE#2106-2-7;
dAppointment : DATE := D#2020-2-7;
// Date and time
dtLowerLimit : DATE_AND_TIME := DATE_AND_TIME#1970-1-1-0:0:0;
dtUpperLimit : DATE_AND_TIME := DATE_AND_TIME#2106-02-07-06:28:15;
dtAppointment : DT := DT#2020-2-7-12:55:1.234;
// Time of day
tdLowerLimit : TIME_OF_DAY := TIME_OF_DAY#0:0:0;
tdUpperLimit : TIME_OF_DAY := TIME_OF_DAY#23:59:59.999;
tdAppointment : TOD := TOD#12:3:4.567;
// Long date
dLowerLimit : LDATE := LDATE#1970-1-1;
dUpperLimit : LDATE := LDATE#2106-2-7;
dAppointment : LDATE := LD#2020-2-7;
// Long date and time
dtLowerLimit : LDATE_AND_TIME := LDATE_AND_TIME#1970-1-1-0:0:0;
dtUpperLimit : LDATE_AND_TIME := LDATE_AND_TIME#2262-4-10-23:59:59.99999999;
dtAppointment : LDT := LDT#2020-2-7-12:55:1.234567891;
// Long time of day
tdLowerLimit : LTIME_OF_DAY := LTIME_OF_DAY#0:0:0;
tdUpperLimit : LTIME_OF_DAY := LTIME_OF_DAY#23:59:59.999999999;
tdAppointment : LTOD := LTOD#12:3:4.567890123;
END_VAR
See also:
- Date and time constants
- TIME/LTIME
- TIME/LTIME constants
- DATE/DT_TO_<type>
- FileTime data type T_FILETIME64 from the Tc2_Utilities PLC library
- DC Time data type T_DCTIME64 from Tc2_EtherCAT PLC library