RecodeDay
The RecodeDay function replaces the day for the specified TDateTime value.
The function converts the date/time value specified by AValue, with the value obtained by changing the day of the month within AValue to the day specified with ADay.
Valid accepted values for ADay range from 1 to 31, and are dependent on the number of valid days available within the month specified by AValue. For instance, you could not specify ADay as 30 for the month of February.
If the value provided for ADay is not within the allowable range so it does not represent a valid day for the month, then RecodeDay raises an exception error.
Declaration: Function RecodeDay(const AValue: TDateTime; const ADay: Word): TDateTime;
An example would be as follows.
procedure
OnMapEvent(
var
Value:Variant);
var
TheDate, ThatDate : TDateTime;
begin
TheDate := EncodeDateTime(
2024
,
06
,
25
,
00
,
00
,
00
,
000
);
//If Date is 2024-06-25 then the result is 2024-06-12
ThatDate := RecodeDay(TheDate,
12
);
LogInfo(FormatDateTime(
'dd-mm-yyyy hh:nn:ss.zzz'
, ThatDate));
//This will produce an error - June does not have 31 days
ThatDate := RecodeDay(TheDate,
31
);
LogInfo(FormatDateTime(
'dd-mm-yyyy hh:nn:ss.zzz'
, ThatDate));
end
;