YourDate2 := IncMonth(YourDate, -1);

解决方案 »

  1.   

    var
      PreYear,PreMonth: integer;
      YourDate: DateTime;PreYear:=YearOf(IncMonth(YourDate, -1));
    PreMonth:=YearOf(IncMonth(YourDate, -1));
      

  2.   

    下面的是我在一个程序中写的一些代码,你可以参考一下就可以实现你想要的了:
    workeryear:=strtoint(pyyear.Text) div 12;
            workermonth:=strtoint(pyyear.Text) mod 12;
            endyear:=strtoint(copy(datetostr(inDwdata.date),1,4))+workeryear;
            endmonth:=strtoint(copy(datetostr(inDwdata.date),6,2))+workermonth;
            if endmonth>12 then begin endyear:=endyear+1;endmonth:=endmonth-12;end;
            endday:=strtoint(copy(datetostr(inDwdata.date),9,2));
            tempyear:=endyear;
            case endmonth of
                    4,6,9,11:   if endday=31 then endday:=endday-1;
                           2:   begin
                                   if (tempyear mod 4)=0
                                   then begin
                                          if endday=31 then endday:=endday-2;
                                          if endday=30 then endday:=endday-1;
                                        end
                                   else begin
                                          if endday=31 then endday:=endday-3;
                                          if endday=30 then endday:=endday-2;
                                        end;
                                end;
            end;
            enddate:=inttostr(endyear)+'-'+inttostr(endmonth)+'-'+inttostr(endday);
      

  3.   

    我刚刚专门试过没有问提!!!给分吧!!!!procedure TForm1.Button1Click(Sender: TObject);
    var
            year,month,day:word;
    begin
            decodedate(strtodatetime(dxdateedit1.Text),year,month,day);
            if (month-1)>0 then
               label1.Caption:=inttostr(year)+'-'+inttostr(month-1)+'-'+inttostr(day)
            else
               label1.Caption:=inttostr(year-1)+'-'+inttostr(month)+'-'+inttostr(day);
    end;
      

  4.   

    to linbee(linbee) ;
    我在edit里输入2002-01-01不好使;
      

  5.   

    YourDate2 := IncMonth(YourDate, -1);
     .............incyear(yourdate,-1);
    ...............incday(yourdate,-1);
    都可以
      

  6.   

    YourDate2 := IncMonth(YourDate, -1);
     .............incyear(yourdate,-1);
    ...............incday(yourdate,-1);
    都可以