Mega Code Archive

 
Categories / Delphi / Algorithm Math
 

How to get the last day of the current month

Title: How to get the last day of the current month 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;