How to provide a date variable an interval that consists of an integer variable in Postgresql
Posted
by
Lucius Rutilius Lupus
on Stack Overflow
See other posts from Stack Overflow
or by Lucius Rutilius Lupus
Published on 2012-11-04T21:11:41Z
Indexed on
2012/11/04
23:00 UTC
Read the original article
Hit count: 449
I am trying to extract an amount of years from a specific date for this the correct syntax is
<date> - interval '5 years';
But I dont want to extract a specific amount of years but a variable, which user will provide as a parameter. I have tried the following the variable name is years :
date+interval '% years',years;
I am getting an error and it doesn't let me do it that way. What would be the right way to do it.
© Stack Overflow or respective owner