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
(01.01.1970)

4294967295 = D#2106-02-07
(07.02.2106)

32-bit

Seconds, although only the day is displayed.

DATE_AND_TIME
DT

0 = DT#1970-1-1-0:0:0
(01.01.1970, 00:00 h)

4294967295 = DT#2106-02-07-06:28:15
(07.02.2106, 6:28:15)

32-bit

Seconds

TIME_OF_DAY
TOD

0 = TOD#0:0:0
(00:00:00:000 h)

86399999 = TOD#23:59:59.999
(23:59:59.999 h)

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
(01.01.1970)

264-1 = LD#2554-7-21
(21.07. 2554)

64-bit

Nanoseconds, although only the day is displayed.

LDATE_AND_TIME
LDT

0 = LDT#1970-1-1-0:0:0
(01.01.1970, 00:00 h)

264-1 = LDT#2554-7-21-23:34:33.709551615
(21.07.2554, 23:34:33.709551615 h)

64-bit

Nanoseconds

LTIME_OF_DAY
LTOD

0 = LTOD#0:0:0
(00:00:00:000 h)

86399999999999 = LTOD#23:59:59.999999999
(23:59:59.999999999 h)

64-bit

Nanoseconds

Date and time data types 1:

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: