@Adjust (Formula Language)

Adjusts the specified time-date value by the number of years, months, days, hours, minutes, and/or seconds you specify. The amount of adjustment may be positive or negative.

Syntax

@Adjust( dateToAdjust ; years ; months ; days ; hours ; minutes ; seconds ; [DST] )

Parameters

dateToAdjust

Time-date or time-date list. The time-date value you want to increment. This should be a single date, not a range.

years

Number. The number of years to increment by.

months

Number. The number of months to increment by.

days

Number. The number of days to increment by.

hours

Number. The number of hours to increment by.

minutes

Number. The number of minutes to increment by.

seconds

Number. The number of seconds to increment by.

[DST]

Keyword. Optional. Specify [INLOCALTIME] to further adjust the time for daylight-saving time if the adjustment crosses the boundary and daylight-saving time is in effect. Specify [INGMT] or omit this parameter to not further adjust the time for daylight-saving time. The adjustment is such that adding or subtracting in day increments yields the same time in the new day.

Return value

adjustedDate

Time-date. The date, incremented by the amount of time you have specified.

Usage

If the first parameter is a list, the function operates on each element of the list, and the return value is a list with the same number of elements.

You must include all arguments except the [DST] keyword; include a zero (0) for parameters you don't want to adjust.

The arguments are applied from last to first. For instance, @Adjust([2/2/2006]; 0; 2; 28; 0; 0; 0) returns [5/2/2006], not [4/30/2006] as you might expect. This is because @Adjust first adds 28 days, making [3/2/2006], then adds two months, making [5/2/2006]. To first add two months, then add 28 days, use @Adjust twice, for instance: @Adjust(@Adjust([02/02/2006]; 0; 2; 0; 0; 0; 0); 0; 0; 28; 0; 0; 0)

Tip: To find the difference between two dates, subtract them. The result is returned in seconds. To adjust the result to days, divide the result by 86,400 - which is the number of seconds in a day. For example, if you have two date fields, date1, which contains [07/01/01] and date2, which contains [07/05/01], use the following formula to return the number of days between the two dates:
(date2-date1)/86400

This code returns 4.

Calculating due dates

A typical use for @Adjust is calculating a due date from an entry date, by adjusting only one component of the time-date value, for example, the month component.

Examples

  1. This example returns 09/2/97.
    @Adjust([06/30/95];2;2;2;0;0;0)

    Notes/Domino sees 30 in the days portion of the time-date value and adjusts it by 2, which increments the month value by 1. Notes/Domino then adjusts the month value by 2, and the year value by 2.

  2. This example returns 03/20/94.
    @Adjust([03/30/96];-2;0;-10;0;0;0)

    Notes/Domino returns a date that is 2 years and 10 days before the supplied date.

  3. This example returns 09/1/97 and 09/2/97.
    @Adjust([06/29/95] : [06/30/95]; 2; 2; 2; 0; 0; 0)
  4. This example returns the date one month from the date in the field named Date.
    @Adjust(Date;0;1;0;0;0;0) 
  5. This example returns the date one month and one day from the current time-date.
    @Adjust(@Now;0;1;1;0;0;0)
  6. Given a date, this formula calculates the beginning of the week. It takes the date stored in the dueDate field, and returns the date representing the previous Monday. For example, if dueDate is 06/02/95, this formula returns 05/29/95.
    @Adjust( dueDate; 0; 0; - ( @Weekday( dueDate ) - 2 ); 0; 0; 0 )
  7. This example returns 5/2/2006.
    @Adjust([2/2/2006]; 0; 2; 28; 0; 0; 0)
  8. This example returns 4/30/2006.
    @Adjust(@Adjust([02/02/2006]; 0; 2; 0; 0; 0; 0); 0; 0; 28; 0; 0; 0)