Appearance
TryEncodeDateTime
Declaration
Function TryEncodeDateTime(const AYear: Word; const AMonth: Word; const ADay: Word; const AHour: Word; const AMinute: Word; const ASecond: Word; const AMilliSecond: Word; out AValue: TDateTime): Boolean
Example
pascal
procedure OnMapEvent(var Value:Variant);
var
lYear, lMonth, lDay, lHour, lMin, lSec, lMil : word;
lDate: TDateTime;
begin
Value := TryEncodeDateTime(lYear, lMonth, lDay, lHour, lMin, lSec, lMil, lDate); // test creation of a date/time from its parts
end;Description
Tests creation of a valid Datetime value from given parts.
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 within range, the TryEncodeDateTime function returns True and the encoded date/time value is available from AValue
If any of the specified values is not within range, the TryEncodeDateTime function returns False and AValue is set to zero (which can display as 30 Dec 1899).