I am using Postgres 9.0 version. I want to add some months to a date to calculate the new date and update in a table. Here the number of months to be added will be in integer variable. My code is as follows:
declare numberofmonths smallint = 5;
update salereg1 set expdate = current_date + interval cast(numberofmonths as text) month;
The above code shows syntax error at cast. I don't know how to specify the numberofmonths
variable as text.. can anyone help me. what is the mistake I did..