I know you can get the current date and time using the Now()
function, but how would you get the date of yesterday?
CodePudding user response:
You can use the Yesterday
function from DateUtils
as follow:
uses DateUtils;
begin
ShowMessage('Yesterday = ' DateToStr(Yesterday)); // Date of yesterday
ShowMessage('Today = ' DateToStr(Date)); // Date of Today
ShowMessage('Tomorrow = ' DateToStr(tomorrow)); // Date of tomorrow
end;
These functions return a TDateTime
data type. The time component is set to zero.
CodePudding user response:
Why not just use Date - 1
?
Since one day is 1.0 in TDateTime
encoding, substracting 1
is enough.