请较高手 :我再delphi5中怎么进行Tdate类型之间的加减运算date1-date2,而不是date1-27这样的运算date1、date2为Tdate型
解决方案 »
- delphi Image1.Canvas 中的图片 如何保存 到Image2.Canvas 中
- 可否在fastreport交叉报表的列合计后面再添加一列????
- 关于TBooleanField类的属性DisplayValues: String
- COM组件中使用线程的问题?
- 点击TREEVIEW的时候,如何判断结点是那个层次的?比如,我的TREEVIEW有2层,如何知道?谢谢。
- 如何实现时间的相减,并存入数据库?
- Delphi6做的ActiveX控件在其他开发环境里不好使用
- 简单---在线等待
- 唉,结贴率这么低,没动力了,去看书了!
- QuickRep的打印问题!!!
- 紧急求助该c代码如何用delphi来表示,
- 吉安特被盗~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
adoquery1的sql為: select datediff(day,:a1,:a2) function tform1.datediff(date1:tdate;date2:tdate):integer;
begin
with adoquery1 do
begin
adoquery1.Close;
adoquery1.Parameters.ParamByName('a1').Value:=date1;
adoquery1.Parameters.ParamByName('a2').Value:=date2;
adoquery1.Open;
result:=adoquery1.Fields[0].Value;
end;
end;要求date1,date2之間的相差天數,直接用
datediff(date1,date2)
DateUtils里的DaysBetween可以了.
Returns the number of days (including fractional days) between two specified TDateTime values.UnitDateUtilsCategorydatetime routinesDelphi syntax:function DaySpan(const ANow, AThen: TDateTime): Double;C++ syntax:extern PACKAGE double __fastcall DaySpan(const System::TDateTime ANow, const System::TDateTime AThen);DescriptionCall DaySpan to obtain the difference, in days, between two TDateTime values. Unlike the DaysBetween function, which only counts whole days, DaySpan reports incomplete days as a fraction of an entire day.