1

I'm trying to increase the date in Delphi by one day per button click. I'm using the incday function. This is my code:

Procedure ButtonClick
begin
IncDay(currdate,1);
ShowMessage(DateTimeToStr(currdate));
end;

currdate is set to "date" in another procedure.

When the procedure ButtonClick is run, the date remains as the value of the system date.

  • 4
    Remains, because this function returns modified input value, It doesn't modify the input parameter _in-place_. Use `CurrDate := IncDay(CurrDate);` (you can omit increment value 1 as it's default). – Victoria Oct 27 '17 at 20:01
  • 3
    Learn the difference between a function and a procedure. Read the definition of `IncDay`. Or at least try reading the [IncDay documentation](http://docwiki.embarcadero.com/Libraries/Berlin/en/System.DateUtils.IncDay). – Ken White Oct 28 '17 at 00:15
  • 4
    I can imagine that the confusion rooted from how `Inc()` works. – Jerry Dodge Oct 28 '17 at 00:31

0 Answers0