"For developers", "Server scripts", "Functions description", "Date and time", "IncYear"

 

Function to add or subtract the number of years to the specified date.

 

Syntax

function IncYear(dt: double; iYears: int64): double;

 

Parameters or return values

Parameter

Type

Value

dt

double

date/time value to which you need to add or subtract years;

iYears

int64

number of years which you need to add or subtract. If the number is positive — add years, if negative — subtract.

 

Function result

Returns a date shifted by a specified number of years.

 

Example

var
  dt: double;
begin
  dt := Now;
  
  mLogScript(FormatDateTime('mm.dd.yyyy', dt), 'now');
  
  dt := IncYear(dt, 1);
  mLogScript(FormatDateTime('mm.dd.yyyy', dt), '+1 year');
end.

Script work result

[15:11:00] (Log "IncYear"): [now] 02.23.2016

[15:11:00] (Log "IncYear"): [+1 year] 02.23.2017

 

See also

FormatDateTime
mLogScript

Now