comparedatetime函数怎么用?,请帮忙。

解决方案 »

  1.   

    查帮助
    function CompareDateTime(const A, B: TDateTime): TValueRelationship;
    返回:
    LessThanValue if A is earlier than B.
    EqualsValue if A is the same as B.
    GreaterThanValue if A is later than B.
    在看TValueRelationship的定义
    type TValueRelationship = -1..1;一个集合类型如果你写个例子,你会发现tdatetime类型一个很有趣的细节,我们知道一个tdatetime变量对应一个double值,在程序里,即时两个tdatetime变量取同样的year,month,day,hour...它们的double值还是不同的,(我想,应该是由于编译时取值时间不同的差别,虽然编译的速度很快)这些在帮助里也有叙述。
    Note: CompareDateTime differs from a direct comparison of the corresponding Double values in that two TDateTime values are considered the same if they have the same value down to the millisecond. It is possible to create two TDateTime values that differ numerically when viewed as Doubles, but which represent the same year, month, day, hour, minute, second, and millisecond.