怎样返回一个月的总天数!

解决方案 »

  1.   

    var
      Y,M,D,D1:Word;
    begin
       decodedate(tmp,Y,M,D);
       case M of
         1,3,5,7,8,10,12: D1:=31; //大月
                4,6,9,11: D1:=30; //小月
       2:
         begin //二月份的月底日期判斷
           if ((Y mod 4)<>0) then //平年
           begin
             D1:=28;
           end;       if (((Y mod 4)=0)  and ((Y mod 400)<>0)) or ((Y mod 400)=0) then
           begin //閏年
             D1:=29;
           end;
         end;
       end;
      

  2.   

    指定年、月,返回该月的天数
    daysinamonth(year,month:word): word;
      

  3.   

    SysUtils.MonthDaysfunction GetDays(Year, Month: Word): Word;
    begin
      Result := MonthDays[IsLeapYear(Year), Month];
    end;
      

  4.   

    Returns the day of the month represented by a TDateTime value.UnitDateUtilsCategorydate/time routinesfunction DayOfTheMonth(const AValue: TDateTime): Word;DescriptionCall DayOfTheMonth to obtain the day of the month represented by a specified TDateTime value. DayOfTheMonth returns a value between 1 and 31.Note: DayOfTheMonth returns the same value as the DayOf function.