Calculating a Past or Future Date
Use the 'dateAdd()' function to find a date which is n units (days, months, or years) into the past or future.
// 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, consider a query 'Order Bookings' that accepts two date parameters, 'StartDate' and 'EndDate'. Assume you want the query to return data from the date range of 15 days before today's date until 15 days after today's date. Use the dateAdd() function to obtain these dates as follows:
var sd = dateAdd('d', -15, CALC.today());
var ed = dateAdd('d', 15, CALC.today());
var q = runQuery('Order Bookings',
[['StartDate', sd], ['EndDate', ed]]);
| << Finding the Difference Between Dates | © 1996-2013 InetSoft Technology Corporation (v11.4) | Extracting a Date Component >> |