From Clomosy Docs

(Created page with " function IncMonth(const StartDate TclDateTime {; NumberOfMonths Integer = 1}):TclDateTime; The IncMonth function returns a TclDateTime value with NumberOfMonths greater than the passed StartDate. The time component of the StartDate value is passed unchanged to the output value. The year value is incremented accordingly.<br> Increment value is optional, defaults to 1.<br> If the day value is too high for that month/year after the month is increased, it is reduced to...")
 
No edit summary
Line 11: Line 11:
   dateValue : TclDateTime;<br>
   dateValue : TclDateTime;<br>
  '''begin'''
  '''begin'''
   dateValue := StrToDate('28.02.2023');
   dateValue := StrToDate('28 02 2023');
   ShowMessage('dateValue = '+DateToStr(dateValue));<br>
   ShowMessage('dateValue = '+DateToStr(dateValue));<br>
   dateValue := '''IncMonth'''(dateValue, 2);     
   dateValue := '''IncMonth'''(dateValue, 2);     

Revision as of 14:20, 8 January 2024

function IncMonth(const StartDate TclDateTime {; NumberOfMonths Integer = 1}):TclDateTime;

The IncMonth function returns a TclDateTime value with NumberOfMonths greater than the passed StartDate. The time component of the StartDate value is passed unchanged to the output value. The year value is incremented accordingly.

Increment value is optional, defaults to 1.

If the day value is too high for that month/year after the month is increased, it is reduced to the highest value for that month/year.

Example:

var
  dateValue : TclDateTime;
begin dateValue := StrToDate('28 02 2023'); ShowMessage('dateValue = '+DateToStr(dateValue));
dateValue := IncMonth(dateValue, 2); ShowMessage('dateValue + 2 months = '+DateToStr(dateValue)); end;

Output:

dateValue = 28.02.2023
dateValue + 2 months = 28.04.2023