procedure TForm1.FormCreate(Sender: TObject);
var
firstDay,lastDay:TDateTime;
begin
firstDay := StrToDate(FormatDateTime('yyyy-mm-1',IncMonth(Now,-1))); //上个月的第一天
lastDay := IncMonth(firstDay,1)-1; //上个月的最后一天
mmo1.Lines.Add(DateTimeToStr(firstDay));
mmo1.Lines.Add(DateTimeToStr(lastDay));
end;
var
firstDay,lastDay:TDateTime;
begin
firstDay := StrToDate(FormatDateTime('yyyy-mm-1',IncMonth(Now,-1))); //上个月的第一天
lastDay := IncMonth(firstDay,1)-1; //上个月的最后一天
mmo1.Lines.Add(DateTimeToStr(firstDay));
mmo1.Lines.Add(DateTimeToStr(lastDay));
end;