Adding a month to Ansidate

279 views Asked by At
select ansidate(xxx) + '3 months'  AS date1
from (
select str_to_date(varchar(max_date),'%Y%m%d') as xxx
from comp_stg_rundate
where row_key = 1
)as s

Max_date is saved as an interger in the comp_stg_rundate table, I want to add 3 months onto this date. The fuction DateAdd won't work as I am using VectorWise.

2

There are 2 answers

1
PaulM On

What version of Vectorwise did you run this against because it works for me on VW 4.0.

However this also works.

timestampadd(MONTH,3,ansidate(xxx))
0
Bardo On

Ok, I don't know VectorWise or how ansidate is stored, however, if it's stored as an integer value I assume it represents a certain amount of time, measured on a specific time unit since a starting time point.

If it's true, you can convert your 3 months to the time unit in which ansidate is being stored and add the converted value.