AddYearsToDate (open)

Adds a number of years to a date, and returns the new timestamp

Syntax

LOADLIB "wh::datetime.whlib";

DATETIME FUNCTION AddYearsToDate(INTEGER add_years, DATETIME date, RECORD options)

Parameters

INTEGER add_years

The number of years to add to the timestamp. This value can also be negative.

DATETIME date

The timestamp to add the days to

RECORD options

Options

BOOLEAN roundforward

Round up/forward towards next year. Defaults to TRUE

Return value

DATETIME

A DateTime value representing @italic date to which @italic add_years has been added

Description

This function can for example be useful to calculate expiration dates of documents or users.

Examples

// Add 5 years to the current date
INTEGER extrayears := 5;
DATETIME newdate := AddYearsToDate(extrayears, GetCurrentDateTime());