AddDays
Summary
The AddDays
function adds n number of days to the first input parameter.
Syntax
AddDays(<instant|date_time|date|offset_date_time|zoned_date_time>, < long >) |
Return Type
Determined by the data type of the first input parameter value. Valid input parameter types are: instant, date_time, date, offset_date_time, zoned_date_time
.
Details
The AddDays
function allows both positive and negative long values in the second input parameter. Negative values subtract days from the given input “date” parameter.
Examples
/* Add 1, 30, and 365 days to incentive_date */
select incentive_date,
AddDays(incentive_date,1) example_1_day,
AddDays(incentive_date, 30) example_30_days,
AddDays(incentive_date,365) example_365_days
from xactly.xc_order_stage limit 1;
/* Some requirements use the current date to determine if the ETL pipeline should process the prior period or the current period.
This example will run the prior period if Now() is within 4 days of the current period start date.
*/
select name as current_period,
if Now() < AddDays(start_date,4) then ‘Run prior period’ else ‘Run current period’ end as which_period_to_run
from xactly.xc_period
where name = LookupPeriodName(Now(),’monthly’);
select Now() as now_instant,
AddDays(Now(),4) as instant_example_add_4
from Empty();