如何判断某天是大月的29日,还是小月的28日,如果是就发出提示?

解决方案 »

  1.   

    uses DateUtils;
    function DaysInAMonth(const AYear, AMonth: Word): Word;
    可能是你想要的, 得到一個月是有多少天!!
      

  2.   

    函数得到每个月包含多少天uses DateUtils;procedure TForm1.Button1Click(Sender: TObject);
    var
       s1,s2:word;
    begin
       s1:=strtoint(edit1.text);
       s2:=strtoint(edit2.text);
       edit3.text:=inttostr(DaysInAMonth(s1,s2));
    end;
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs,dateutils, StdCtrls ,dateutils//这加;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Button1: TButton;
        Button2: TButton;
        procedure Button1Click(Sender: TObject);
        procedure Button2Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      s:string;implementation
          {$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    edit1.text:=inttostr(daysinamonth(1999,4))
    end;楼上的方法是判断指定年,月,该月的天数.end;
      

  4.   

    var
      n : Word;
      d : TDateTime;
    var
      n : Word;
      d : TDateTime;
    begin
      d := StrToDate('2003-02-28');
      n := DaysInAMonth(Yearof(d), Monthof(d));
      case n of
        28 : showmessage('平年二月');
        29 : showmessage('闰年二月');
        30 : showmessage('小月');
        31 : showmessage('大月');
      end
    end;
      

  5.   

    function DaysInMonth(MYdate:TDate):Integer;
    var
       MyMonth,MyYear,MyDay : Word;
       MyDayTable : TDayTable;
       tmpBool : Boolean;
    begin
       DecodeDate(MYdate, MyYear, MyMonth, MyDay);
       tmpBool := IsLeapYear(MyYear);
       MyDayTable := MonthDays[tmpBool];
       Result := MyDayTable[MyMonth];
    end;
      

  6.   

    function MonthEnd(Date:TDateTime):TDateTime;
    var
     Year, Month, Day{, Hour, Min, Sec, MSec}: Word;
     T:String;
    begin
       Result:=0;
       DecodeDate(Date, Year, Month, Day);
       T:=IntToStr(Year)+'-'+IntToStr(Month)+'-';
       case Month of
        1,3,5,7,8,10,12:Result:=StrToDate(T+'31');
        4,6,9,11       :Result:=StrToDate(T+'30');
        2              :if (Year mod 4 =0) and ( Year mod 100 <> 0 )
                              or (Year mod 400 =0 )
                        then
                            Result:=StrToDate(T+'29')
                        else
                            Result:=StrToDate(T+'28');
       end;
    end;
    看看这个可能对你有启示