Delphi - Error comparing dates

2

I made a comparison between two dates. When the variable 'date' contains the TODAY date, the code understands that it is smaller

if data < now then

  begin

  ...//se a variável DATA fosse igual a hoje (now), ele iria executar esse comando como se DATA fosse menor que NOW

  end;
    
asked by anonymous 29.08.2016 / 22:04

1 answer

4

Possibly there is "confusion" in the now , which contains hour / minute / second and in the field armanezado can be any other value. To resolve, you can use the command trunc :

if trunc(data) < trunc(now) then

This should solve your problem.

    
29.08.2016 / 22:39