Reputation: 791
Looking for a code sample that returns the difference in seconds between two TDateTime values. Specifically, I am trying to compare two TDateTime values and if greater than a second threshold it will run a specific method.
Thanks!
Upvotes: 29
Views: 49929
Reputation: 136431
Try the SecondsBetween
function which is part of the DateUtils unit.
Sample of use
SecondsBetween(Now, IncSecond(Now,10))
Will return 10
Upvotes: 53
Reputation: 613441
Call SecondsBetween
from the DateUtils
unit. For example:
Assert(SecondsBetween(MyAnswer, RRUZsAnswer)=7)
Upvotes: 26