怎样的函数或者算法能解决以下的问题:  如何能得到当前日期后的每个月的今天,如果当前日期是月底的话,则生成每个月底的日期。截止到一个日期。比如我有个日期是2003-05-20 ,今天是2004-8-11 ,日期间隔是3个月,要求自动生成以下日期:
  2003-05-20
  2003-08-20
  2003-11-20
  2004-2-20
  2004-5-20
谁知道怎样解决,请赐教.

解决方案 »

  1.   

    引用DateUtils单元, 使用IncMonth函数,与它相差的还有IncYear等, 你可以看一下帮助
    例: ShowMessage(DateToStr(IncMonth(Date)));
      

  2.   

    ShowMessage(DateToStr(IncMonth(Date, 3)));
      

  3.   

    function IncYear(const AValue: TDateTime;
      const ANumberOfYears: Integer = 1): TDateTime;
    // function IncMonth is in SysUtils
    function IncWeek(const AValue: TDateTime;
      const ANumberOfWeeks: Integer = 1): TDateTime;
    function IncDay(const AValue: TDateTime;
      const ANumberOfDays: Integer = 1): TDateTime;
    function IncHour(const AValue: TDateTime;
      const ANumberOfHours: Int64 = 1): TDateTime;
    function IncMinute(const AValue: TDateTime;
      const ANumberOfMinutes: Int64 = 1): TDateTime;
    function IncSecond(const AValue: TDateTime;
      const ANumberOfSeconds: Int64 = 1): TDateTime;
    function IncMilliSecond(const AValue: TDateTime;
      const ANumberOfMilliSeconds: Int64 = 1): TDateTime;
      

  4.   

    function IncMonth is in SysUtils