function DayOfTheMonth(const AValue: TDateTime): Word;

解决方案 »

  1.   

    function DaysInMonth(const AValue: TDateTime): Word;
      

  2.   

    To chechy(chechy):
    好象delphi中没有这个函数,我用的时候出错了:
    Undeclared identifier: 'dayofthemonth'  
      

  3.   

    To  chechy(chechy):
    是不是还要声明什么?多多指教啊。
      

  4.   

    D6中,uses DateUtils;
    我看错了,应该是
    function DaysInAMonth(const AYear, AMonth: Word): Word;
    begin
      Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
    end;
      

  5.   

    To  chechy(chechy):
      我用的是delphi5,uses  DateUtils不行啊,
      请问delphi5中uses ???.
      

  6.   

    D5还没有了。那么卧抄一下给你:
    const
      MonthDays: array [Boolean] of TDayTable =
        ((31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31),
         (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31));function IsLeapYear(Year: Word): Boolean;
    begin
      Result := (Year mod 4 = 0) and ((Year mod 100 <> 0) or (Year mod 400 = 0));
    end;function DaysInAMonth(const AYear, AMonth: Word): Word;
    begin
      Result := MonthDays[(AMonth = 2) and IsLeapYear(AYear), AMonth];
    end;
      

  7.   

    chechy这么严谨的人也写了个别字,呵呵,有趣
                                               收藏
      

  8.   

    chechy这么严谨的人也写了个大别字,呵呵,有趣
                                               收藏
      

  9.   

    function DaysOfMonth(ADate: TDateTime): Word;
    var
      Year,Month,Day: Word;
    begin
      DecodeDate(ADate,Year,Month,Day);
      Result := MonthDays[IsLeapYear(Year),Month];
    end;
    哎呀!累死我了,请给分!
      

  10.   

    8仙过海,我来介绍另一种办法:
      
    function DaysOfItsMonth(ADate: TDateTime): Word;
    var
        Y, M, D: Word;
    begin
      DecodeDate( ADate, Y, M, D );
      ADate := EncodeDate( Y, M, 1 );
      Result := Trunc( IncMonth(ADate, 1)-ADate );
    end;