问题描述
我想要一个比较时间的方法,例如,如果Atime早于Btime发生的话,我会使用一个CompareTime函数,但是我使用这个函数的问题就是粗体括号中的内容(见下文)
如果A发生在B的早一天(即使A晚于B 发生)。如果A发生在当天晚于B (即使A发生在早于B 的早一天),则为更大的值。
一个 TDateTime
值可以被认为包含两个不同的部分:日期部分和时间部分。 CompareTime
功能只比较时间部分并忽略日期部分。 说:
您想要比较整个日期时间值。为此,您应该使用。该功能的中的一个重要说明是:
I want a method which compares the times, eg if Atime occurs earlier than Btime do something, I would use a CompareTime Function but my problem with this function is what is said in "Bold Brackets" (see below)
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).GreaterThanValue if A occurs later in the day than B (even if A occurs on an earlier day than B).
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:
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:
这篇关于比较时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!