The EndOfTheMonth function returns a DateTime that is the last possible millisecond for the month specified in the given date parameter AValue.

The time will always result in 23:59:59.999 which can be formatted as required.

Declaration: Function EndOfTheMonth(const AValue: TDateTime): TDateTime;

An example follows that also displays the result.

procedure OnMapEvent(var Value:Variant);
var
vEOM ; TDateTime;
begin
//If the date is 2009-06-25 then the result is 2009-06-30 23:59:59.999
vEOM := EndOfTheMonth(Date);
LogInfo(FormatDateTime('dd mmm yyyy hh:nn:ss:zzz', vEOM));
end;