Dynamic (Column Based) Interval

explodes picture explodes · Mar 10, 2011 · Viewed 29k times · Source

How do I add a dynamic (column based) number of days to NOW?

SELECT NOW() + INTERVAL a.number_of_days "DAYS" AS "The Future Date" 
FROM a;

Where a.number_of_days is an integer?

Answer

araqnid picture araqnid · Mar 10, 2011

I usually multiply the number by interval '1 day' or similar, e.g.:

select now() + interval '1 day' * a.number_of_days from a;