@Adjust (JavaScript)

Adjusts a time and date by years, months, days, hours, minutes, and/or seconds.

Defined in

@Functions (JavaScript)

Syntax

@Adjust(time:Date, years:int, months:int, days:int, hours:int, minutes:int, seconds:int) : Date

@Adjust(time:Date, years:int, months:int, days:int, hours:int, minutes:int, seconds:int, keywords:string) : Date

Parameter Description
time A time and date.
years Number of years.
months Number of months.
days Number of days.
hours Number of hours.
minutes Number of minutes.
seconds Number of seconds.
keywords [InLocalTime] adjusts for daylight saving time: if an adjustment crosses the daylight saving boundary and daylight saving is in effect, the adjustment is such that adding or subtracting a day yields the same hour; otherwise no adjustment for daylight saving is made. A keyword must be exact except for case. An incorrect keyword is ignored.
Return value Description
Date The adjusted time and date.

Usage

An adjustment can be positive or negative. Decimals are truncated.

Zero (0) or null means no adjustment.

An overflow increments or decrements the next larger field and adjusts the field value back into its range.

Examples

This example marks the current document OBSOLETE if the current date and time exceeds the creation date and time adjusted forward by 30 days.
var s = "ACTIVE";
var xdate = @Adjust(@Created(), null, null, 30, null, null, null, "[InLocalTime]");
if(@Now() > xdate) s = "OBSOLETE";
return s;

This example is the same as the previous example but does not adjust for daylight saving time.

var s = "ACTIVE";
var xdate = @Adjust(@Created(), null, null, 30, null, null, null);
if(@Now() > xdate) s = "OBSOLETE";
return s;