00 Votes

Delphi/Lazarus: Date of tomorrow

Question by Compi | Last update on 2020-10-20 | Created on 2017-02-25

Is it possible to determine the date of tomorrow with Delphi or Lazarus? Up to now, I only made to output the date of today using the function "now". Is there also a function for tomorrow?

ReplyPositiveNegative
0Best Answer0 Votes

Basically, there are two possibilities for determining tomorrows date.

First, you can just use the function Tomorrow available from the unit DateUtils. Tomorrow returns the date of tomorrow in the DateTime format (the time component is 0 o'clock), so that you can use this function the same way you can use the Now function:

var
  s: string;
  d: TDateTime;
begin
  d := Tomorrow;
  s := FormatDateTime('yyyy-mm-dd', d);
  ShowMessage(s);
end;

The second possibility is to just take Now with adding one additional day:

FormatDateTime('yyyy-mm-dd', now + 1);

You should know for this that TDateTime is just a simple point number, where the days are saved before the decimal separator at the time behind, so that you can quite simple add or substract days from a given DateTime.
Last update on 2020-10-20 | Created on 2017-02-26

ReplyPositive Negative
Reply

Related Topics

PHP: Current Date and Time

Tutorial | 0 Comments

PHP: Determine Week Number

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.