Transferred from: original article link
Demand: Increase by year (month, day)
Declaration: function incyear (const startdate: tdatetime {; numberofyears: integer = 1}): tdatetime;
Description: The incyear function adds the number of years of numberofyears to the startdatetime parameter passed in.
The increase or decrease quantity is optional. The default value is 1.
After the year is added, if the number of days is too large for the current year and month, it is automatically reduced to the maximum date value of the current year and month.
Example:
Incyear (now); // the current date plus one year
Incyear (now, 5); // the current date plus 5 years
Incyear (now,-1); // the current date minus 1 year
The incmonth () function is called when the month is to be operated, and the incday () function is called when the day is manipulated. The usage is similar.
There are also incweek (), inchour (), incminute (), incsecond () and so on.
Note: There is no decyear function. On the contrary, a negative number is used in incyear to Increase the number.
Requirement: Add 1 or N (minus 1 or minus N) to I in a loop)
INC () or Dec ();
Example
Procedure tform1.test ();
VaR
I: integer;
Begin
I: = 0;
For Y: = 0 to 100 do
Begin
INC (I); // each time to I + 1;
INC (I, 5); // each time I + 5;
Dec (I); // each time to the I-1;
Dec (I, 5); // each time to the I-5;
End;
End;