Altair® Monarch®

 

Function: DateAdjust

While adjusting a date by any number of days can be done using simple date arithmetic (i.e., adding or subtracting an integer value to/from a date), adjusting a date by months or years can be more difficult, since it is necessary to take into account leap years and the varying number of days in each month when doing so.

Description

Returns the given date value adjusted forward or backward by the given integral number of years, months, and optionally, days.

DateAdjust does not adjust the time portion, if any, of the given date/time value. Thus, the adjusted date/time value will represent the same time on a different date. Note that the highest possible adjusted date is 9998.

Syntax

DateAdjust(date,years[,months[,days]])

Arguments

Date specifies the date field to adjust forward or backward.

Years specifies the number of years to adjust date forward or backward.

Months specifies the number of months to adjust date forward or backward.

Days specifies the number of days to adjust date forward or backward. If this optional argument is omitted, it defaults to zero.

Note: The values passed in for the years, months, and days parameters are taken to be integers. Any fractional portions of these values are simply ignored. Negative values adjust the date backward, positive values adjust forward.

Return value

This function returns a date.

Calculated field example

If the Ship_date field contained the value 4/6/2006, the following calculated field expression would return a value of 5/7/2007 (i.e., 1 year, 1 month and 1 day after the ship date: DateAdjust(Ship_date,1,1,1)

Editing the expression to read "DateAdjust(Ship_date,-1,-1,-1)" would return a value of 3/5/2005, i.e., 1 year, 1 month and 1 day before the ship date of 4/6/2006.