uses DateUtils; //for Delphi6function DaysInAMonth(const AYear, AMonth: Word): Word; //for Delphi5
begin
  Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
end;

解决方案 »

  1.   

    uses DateUtils; //for Delphi6function DaysInAMonth(const AYear, AMonth: Word): Word; //for Delphi5
    begin
      Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
    end;
    //or
    function DaysInAMonth(const AYear, AMonth: Word): Word;
    begin
      case AMonth of
        1, 3, 5, 7, 8, 10, 12: Result := 31;
        2: if IsLeapYear(AYear) then
          Result := 28
        else Result := 29;
      else Result := 30;
      end;
      Result := MonthDays[(AMonth = 2) and , AMonth];
    end;
      

  2.   

    可以将参数传到sql serverdeclare
      @test_month char(6)
    select datediff(day,cast((@test_month+'01') as datetime),dateadd(month,1,cast((@test_month+'01') as datetime)))
      

  3.   

    Edit1.Text:=inttostr(DaysInAMonth(1999,7));
      

  4.   

    对,DaysInAMonth()这个函数好用!
      

  5.   

    Calendar从视觉上是可以知道一个月有多少天的!应该为灰色的表示否,为黑色的表示在一个月的天数!