定义一个日期字段tdate,k:=2002-1-1;怎样实行月加1,变成,2002-2-1

解决方案 »

  1.   

    用IncMonth函数
    function IncMonth(const Date: TDateTime; NumberOfMonths: Integer): TDateTime;
    NumberOfMonths为正是增加月份,为付是减少月份。
    关于日期的操作,可以查看Delphi Help中的TDateTime type.incmonth(yourdate,+1)例:
    var
    theday:Tdate;
    str:string;
    begin
      theday:=encodedate(2000,5,31); //获得日期‘2000-5-31’
      theday:=incmonth(theday,+1); 
      str:= datetostr(theday);
      form1.Canvas.TextOut(100,100,str);
    end;
      

  2.   

    请查阅EncodeDate及DecodeDate函数,你就知道了
      

  3.   

    cg1120(代码最优化-§新年祝福你,好运伴着你) 说的是一种方法,如果是在数据库中的话还有一个func 就可以实现的.