IsValidDateTime is a combination of 2 individual functions, and returns True if the given date and time parts would return a valid date and time. 

This function is useful for testing the date and time parts prior to passing them to the EncodeDateTime function.

Declaration: function IsValidDateTime(const AYear: Word; const AMonth: Word; const ADay: Word; const AHour: Word; const AMinute: Word; const ASecond: Word; const AMilliSecond: Word): Boolean;

An example of its use follows.

procedure OnMapEvent(var Value:Variant);
var
vReal, vReal2 ; boolean;
begin
//Returns true if the given date parts would create a valid date
vReal := IsValidDateTime(2009, 06, 25, 15, 45, 23, 562); //VALID
if vReal = True then
loginfo('vReal date/time parts are valid.')
else
LogInfo('vReal date/time has an invalid component.');
vReal2 := IsValidDateTime(2024, 02, 30, 15, 45, 23, 562); //INVALID
if vReal2 = True then
loginfo('vReal2 date/time parts are valid.')
else
LogInfo('vReal2 date/time has an invalid component.');
LogInfo('');
end;