一个月有几天,我可以搞定!
function TForm1.DaysInMonth(ADate:TDateTime):Integer;
var
MyMonth,
MyYear,
MyDay : Word;
MyDayTable : TDayTable;
tmpBool : Boolean;
begin
DecodeDate(ADate, MyYear, MyMonth, MyDay);
tmpBool := IsLeapYear(MyYear);
MyDayTable := MonthDays[tmpBool];
Result := MyDayTable[MyMonth];
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MyDate : TDateTime;
tmpStr : String;
tmpInt : Integer;
begin
MyDate := Date() + 365 - (30*5);
tmpStr := FormatDateTime('mmmm yyyy',MyDate);
tmpInt := DaysInMonth(MyDate);
ShowMessage(tmpStr + '有 ' + IntToStr(tmpInt) + '天');
end;