怎样根据当前日期得到本月的最后一天的日期呀

解决方案 »

  1.   

    function theLastDay(const aYear, aMonth : Word) : TDateTime; //呵呵
      begin
        try
          result := EncodeDate(aYear, aMonth, 1);         //本月1号
          result := IncMonth(result, 1);                  //下月1号
          result := result - 1;                           //下月1号的前1天
        except
          result := 0;
        end;
      end;
      

  2.   

    function EndOfMonth(const Date: TDateTime): TDateTime;
    var
    yyyy, mm, dd: Word;
    begin
    DecodeDate(Date, yyyy, mm, dd);
    Result := EncodeDate(yyyy, mm, MonthDays[IsLeapYear(yyyy), mm]);
    end;//这个也行。。每个月的在数也就是最后一天。。
      

  3.   

    showmessage(datetostr(strtodatetime('2005-03-01')-1));
    也就是用下个月的第一天减一就是本月的最后一天,最简单的方法 @_@