2.5.2 Calculating a Past or Future Date
The 'dateAdd()' function is used to find a date which is n number of days/months/years before/after another date.
// 1 day before today
dateAdd('d', -1, CALC.today());
// 5 months after today
dateAdd('m', 5, CALC.today());
// 3 years before Order Date
dateAdd('yyyy', -3, field['Order Date']);
For example, wish to run a query in script; this query takes in two date parameters namely 'StartDate' and 'EndDate'. You want the query to always fetch data which is 15 days before the today and 15 days after today.
var sd = dateAdd('d', -15, CALC.today());
var ed = dateAdd('d', 15, CALC.today());
var q = runQuery('Order Bookings', [['StartDate', sd],['EndDate', ed]]);
| << 2.5.1 Finding Difference Between Dates | © 1996-2013 InetSoft Technology Corporation (v11.4) | 2.5.3 Extracting a Date Component >> |