32-bit date specifications 'DATE'
Use the keyword DATE
(D
) to specify a date.
Syntax
<date keyword>#<year>-<month>-<day> <date keyword> : DATE | date | D | d <year> : 1970-2106 <month> : 1-12 <day> : 1-31
DATE
literals are treated internally as data type DWORD
, which corresponds to an upper limit of DATE#2106-2-7
.
Example
PROGRAM PRG_Date VAR dateStart : DATE := DATE#2018-8-8; dateEnd : DATE := D#2018-8-31; dateCompare: DATE := date#1996-05-06; xIsDuringTheTime: BOOL; dateEarliest : DATE := d#1970-1-1; // = 0 dateLatest : DATE := DATE#2106-2-7; // = 4294967295 END_VAR IF dateStart < dateCompare THEN IF dateCompare < dateEnd THEN xIsDuringTheTime := TRUE; END_IF; END_IF
64-bit date specifications 'LDATE'
Use the keyword LDATE
(LD
) to specify a date.
Syntax
<date keyword>#<year>-<month>-<day> <date keyword> : LDATE | ldate | LD | ld <year> : 1970-2262 <month> : 1-12 <day> : 1-31
LDATE
literals are treated internally as data type LWORD
, which corresponds to an upper limit of DATE#2554-7-21
.
Example
PROGRAM PRG_Ldate VAR ldateStart : LDATE := LDATE#2018-8-8; ldateEnd : LDATE := ldate#2018-8-31; ldateCompare: LDATE := LD#1996-05-06; xIsDuringTheTime: BOOL; ldateEarliest : LDATE := ld#1970-1-1; // = 0 ldateLatest : LDATE := LDATE#2262-4-10; // = 16#7FFF63888C620000 lwValue: LWORD; END_VAR IF ldateStart < ldateCompare THEN IF ldateCompare < ldateEnd THEN xIsDuringTheTime := TRUE; END_IF; END_IF lwValue := LDATE_TO_LWORD(ldateCompare);
32-bit date and time specifications 'DATE_AND_TIME'
Use the keyword DATE_AND_TIME
(DT
) to specify a date and time.
Syntax
<date and time keyword>#<date and time value> <date and time keyword> : DATE_AND_TIME | date_and_time | DT | dt <date and time value> : <year>-<month>-<day>-<hour>:<minute>:<second> <year> : 1970-2106 <month> : 1-12 <day> : 1-31 <hour> : 0-24 <minute> : 0-59 <second> : 0-59
DATE_AND_TIME
literals are treated internally as data type DWORD
. The time is processed in seconds and as a result can take on values from January
1, 1970 00:00 to February 7, 2106 06:28:15.
Example
PROGRAM PLC_PRG VAR dtDate : DATE_AND_TIME := DATE_AND_TIME#1996-05-06-15:36:30; dtDate1: DATE_AND_TIME := DT#1972-03-29-00:00:00; dtDate2: DATE_AND_TIME := DT#2018-08-08-13:33:20.5; dtEarliest : DATE_AND_TIME := DATE_AND_TIME#1979-1-1-00:00:00; // 0 dtLatest : DATE_AND_TIME := DATE_AND_TIME#2106-2-7-6:28:15; // 4294967295 END_VAR
64-bit date and time specifications 'LDATE_AND_TIME'
Use the keyword LDATE_AND_TIME
(LDT
) to specify a date and time.
Syntax
<date and time keyword>#<long date and time value> <date and time keyword> : LDATE_AND_TIME | ldate_and_time | LDT | ldt <date and time value> : <year>-<month>-<day>-<hour>:<minute>:<second> <year> : 1970-2106 <month> : 1-12 <day> : 1-31 <hour> : 0-24 <minute> : 0-59 <second> : 0-59 LDATE_AND_TIME#2262-4-10-23:59:59.99999999
DATE_AND_TIME
literals are treated internally as data type LWORD
. The time is processed in seconds and as a result can take on values from January
1, 1970 00:00 to July 21, 2554 23:59:59.999999999.
Example
PROGRAM PLC_PRG VAR ldtDate : LDATE_AND_TIME := LDATE_AND_TIME#1996-05-06-15:36:30; ldtDate1: LDATE_AND_TIME := LDT#1972-03-29-00:00:00; ldtDate2: LDATE_AND_TIME := LDT#2018-08-08-13:33:20.5; dtEarliest : LDT := LDT#1979-1-1-00:00:00; // 0 dtLatest : LDT := LDT#2266-4-10-23:59:59; // = 16#7FFF63888C620000 END_VAR
32-bit time specifications 'TIME_OF_DAY'
Use the keyword TIME_OF_DAY
(TOD
) to specify a time.
Syntax
<time keyword>#<time value> <time keyword> : TIME_OF_DAY | time_of_day | TOD | tod <time value> : <hour>:<minute>:<second> <hour> : 0-23 <minute> : 0-59 <second> : 0.000-59.999
You can also specify fractions of a second. TIME_OF_DAY
literals are treated internally as DWORD
and the value is resolved in milliseconds.
Examples
PROGRAM POU VAR todClockTime : TIME_OF_DAY := TIME_OF_DAY#15:36:30.123; todEarliest : TIME_OF_DAY := TIME_OF_DAY#0:0:0.000; todLatest : TOD := TOD#23:59:59.999; END_VAR
64-bit time specifications 'LTIME_OF_DAY'
Use the keyword LTIME_OF_DAY
(LTOD
) to specify a time.
Syntax
<time keyword>#<time value> <time keyword> : LTIME_OF_DAY | ltime_of_day | LTOD | ltod <time value> : <hour>:<minute>:<second> <hour> : 0-23 <minute> : 0-59 <second> : 0.000-59.999999999
You can also specify fractions of a second. LTIME_OF_DAY
literals are treated internally as LWORD
and the value is resolved in nanoseconds.
Examples
PROGRAM POU VAR ltodClockTime : LTIME_OF_DAY := TIME_OF_DAY#15:36:30.123456789; todEarliest : TIME_OF_DAY := TIME_OF_DAY#0:0:0; todLatest : TOD := TOD#23:59:59.999999999; END_VAR
See also