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.