How can I use Postgres INTERVAL with the value of a table column?

1

INTERVAL is usually used as follows:

select now() + interval '1 month' -> intervalo de tiempo

What I want is to send you in the time interval, the number of months to add but with the value of the column of a table, for example:

tabla.fecha + interval tabla.cantidad_meses 'month'

How can I do this? since syntax error exits when executing.

    
asked by Jhoan Lopez 23.11.2017 в 17:55
source

1 answer

2

This is the syntax:

tabla.fecha + (tabla.cantidad_meses || ' month')::interval

Demo

    
answered by 23.11.2017 / 18:01
source