EncodeDateTime
This function enables you to create a TDateTime value from given individual parts.
There are constraints as to the values that are accepted for the input parameters.
The year must be between 1 and 9999.
Valid month values are 1 through 12.
Valid day values are 1 through 28, 29, 30, or 31, depending on the month value. For example, the possible day values for month 2 (February) are 1 through 28 or 1 through 29, depending on whether or not the year value specifies a leap year.
Valid hour values are 0 through 24. If the specified hour is 24, the minute, second, and millisecond values should all be 0, and the resulting TDateTime value represents midnight at the end of the specified day and the beginning of the next day.
Valid minute values are 0 through 59.
Valid second values are 0 through 59.
Valid millisecond values are 0 through 999.
If the specified values are not within range, EncodeDateTime raises an EConvertError exception.
Declaration: Function EncodeDateTime(const AYear: Word; const AMonth: Word; const ADay: Word; const AHour: Word; const AMinute: Word; const ASecond: Word; const AMilliSecond: Word): TDateTime;
For example.
procedure
OnMapEvent(
var
Value:Variant);
var
lYear, lMonth, lDay, lHour, lMin, lSec, lMil :
word
;
begin
lYear :=
2024
;
lMonth :=
06
;
lDay :=
21
;
lHour :=
19
;
lMin :=
42
;
lSec :=
12
;
lMil :=
789
;
//Create a date/time from its separate parts
Value := EncodeDateTime(lYear, lMonth, lDay, lHour, lMin, lSec, lMil);
end
;
This is the opposite to DecodeDateTime which pulls the pieces apart. More information can be found at DecodeDateTime.