function LastDayOfCurrentMonth: TDate;
var
y, m, d: word;
begin
decodedate(now, y, m, d);
m := m + 1;
if m > 12 then
begin
y := y + 1;
m := 1;
end;
result := encodedate(y, m, 1) - 1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(DateToStr(LastDayOfCurrentMonth));
end;