uses DateUtils;(*
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;
*)
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;
*)
var
s:string;
d:TdateTime;
begin
s:='2002-4-1';
d:=strtoDate(s);
d:=IncDay(d,10);
showmessage(datetostr(d));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
s:string;
d:TdateTime;
begin
s:='2002-12-28';
d:=strtoDate(s);
d:=IncDay(d,10);
showmessage(datetostr(d));
end;
返回值就是2003-01-07
tempday:integer;
tempday:=strtoint(copy(FormatDatetime('yyyy-mm-dd',date),9,2))+10;
DtpNextDate.Date:=StrtoDate(formatDatetime('yyyy',date)+'-'+strtodate(formatdatetime('mm',date))+'-'+formatdatetime('dd',date));
你就用这种方法就可以转换了,不但可以转换天,而且年月日都可以转换