Prajwal Mani Pradhan
Prajwal Mani Pradhan

Reputation: 397

Adding days to date in Netezza

I have a column with dates(reg_dates) and another columns with number of days(num_days) for each id. I want to add number of days(num_days) to columns of dates(reg_dates) to create a new column (new_date) for each id.

So far, I have tried:

  1. select *, sum(date(reg_dates) + interval(num_days)) over(partition by id) as new_date from data;

  2. select *, sum(reg_dates) over(partition by id) as new_date from data; no luck so far.

ADD_MONTHS works but add_days seems to be non-existent in netezza.

I also plan to try converting days to month and using the ADD_MONTHS but wanted to see if there is a more straightforward way to do this in netezza.

Upvotes: 0

Views: 1670

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269693

Does this do what you want?

select d.*, reg_date + num_days * interval '1 day' as new_date
from data;

I'm not sure why you are using window functions based on the description.

Upvotes: 1

Related Questions