P pcw Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-03 #1 如何采用最简办法进行如下日期运算: 今年:2001年02月28日减去2000年01月10日等于多少天?
L lyd_2000 Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-03 #2 var d1,d2:Tdatetime; tsouble; begin d1:=StrToDate('2001-02-28'); d2:=StrToDate('2000-01-10'); ts:=d1-d2; end;
var d1,d2:Tdatetime; tsouble; begin d1:=StrToDate('2001-02-28'); d2:=StrToDate('2000-01-10'); ts:=d1-d2; end;
S sun77wind Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-03 #3 ts得到的可不是天数,还要运算。不如这样: var year,mon,day:word; year1,mon1,day1:word; begin decodeDate(StrToDate('2001-02-28'),year,mon,day); decodeDate(StrToDate('2001-02-20'),year1,mon1,day1); caption := INtToSTr(day-day1); end;
ts得到的可不是天数,还要运算。不如这样: var year,mon,day:word; year1,mon1,day1:word; begin decodeDate(StrToDate('2001-02-28'),year,mon,day); decodeDate(StrToDate('2001-02-20'),year1,mon1,day1); caption := INtToSTr(day-day1); end;
左 左右手 Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-05 #6 这样: var year,mon,datelong:word; day,day1:datetime; begin decodeDate(day-day1,year,mon,datelong);//day和day1分别为你需要的日期 caption := INtToSTr(datelong); end;
这样: var year,mon,datelong:word; day,day1:datetime; begin decodeDate(day-day1,year,mon,datelong);//day和day1分别为你需要的日期 caption := INtToSTr(datelong); end;
F FlyingKing Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-05 #7 你试一试下面的方法,引用MATH unit caption:=IntToStr(Ceil(Date1-Date2));
L lipingcool Unregistered / Unconfirmed GUEST, unregistred user! 2001-02-08 #8 记住DELPHI中的DATETIME类型为即为浮点型,整数部分为年月日,小数部分为时分秒