Comparing Time Values

半城伤御伤魂 提交于 2019-12-01 01:51:31

A TDateTime values can be thought of as containing two distinct parts: the date part and the time part. The CompareTime function only compares the time part and ignores the date part. The documentation says:

Indicates the relationship between the time portions of two TDateTime values.

Call CompareTime to compare the two TDateTime values specified by A and B. CompareTime returns:

  • LessThanValue if A occurs earlier in the day than B (even if A occurs on a later day than B).
  • EqualsValue if A occurs at the same time of day as B, ignoring the date portion of the two values.
  • GreaterThanValue if A occurs later in the day than B (even if A occurs on an earlier day than B).

You want to compare the entire date time value. To do that you should use CompareDateTime. One important note in the documentation for the function states:

Note: CompareDateTime differs from a direct comparison of the corresponding double precision 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!