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...") |
ClomosyAdmin (talk | contribs) No edit summary |
||
| (5 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
<div class="alert alert-ligth border border-3 border-primary-subtle rounded-5 p-4 shadow-sm" role="alert"> | |||
function IncMonth(const DateTime: TclDateTime; NumberOfMonths: Integer):TclDateTime; | |||
</div> | |||
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> | 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> | ||
| Line 7: | Line 9: | ||
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.<br> | 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.<br> | ||
<b>Example</b><br> | |||
dateValue : TclDateTime; | <pre> | ||
var | |||
dateValue | dateValue : TclDateTime; | ||
ShowMessage('dateValue = '+DateToStr(dateValue)); | |||
dateValue | { | ||
dateValue = StrToDate('28 02 2023'); | |||
ShowMessage('dateValue = '+DateToStr(dateValue)); | |||
dateValue = IncMonth(dateValue, 2); | |||
ShowMessage('dateValue + 2 months = '+DateToStr(dateValue)); | ShowMessage('dateValue + 2 months = '+DateToStr(dateValue)); | ||
} | |||
</pre> | |||
<b>Output:</b><br> | |||
<div class="alert alert-success" role="alert" data-bs-theme="light"> | |||
dateValue = 28.02.2023<br> | |||
dateValue + 2 months = 28.04.2023 | |||
</div> | |||
<h2> See Also </h2> | |||
* [[System_Library#Date_and_Time_Functions | Date and Time Functions]] | |||
{{#seo:|title=IncMonth Using in Clomosy - Clomosy Docs} | |||
{{#seo:|description=IncMonth increments a given date by a specified number of months, adjusting the day if needed for the new month/year, while preserving the time component.}} | |||
Latest revision as of 13:59, 24 December 2024
function IncMonth(const DateTime: TclDateTime; NumberOfMonths: Integer):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;
{
dateValue = StrToDate('28 02 2023');
ShowMessage('dateValue = '+DateToStr(dateValue));
dateValue = IncMonth(dateValue, 2);
ShowMessage('dateValue + 2 months = '+DateToStr(dateValue));
}
Output:
dateValue = 28.02.2023
dateValue + 2 months = 28.04.2023
See Also
{{#seo:|title=IncMonth Using in Clomosy - Clomosy Docs}