Rahadian Wiratama
Rahadian Wiratama

Reputation: 344

ADD_MONTHS in PostgreSQL

I have issue change ADD_MONTHS Oracle to PostgreSQL.

I have Oracle query like this :

ADD_MONTHS (to_date(to_char(start_billdate,'DD-MM-YYYY'),'DD-MM-YYYY'), 
           (processed_num*periodvalue)
           )

So how to implement that query to PostgreSQL?

Upvotes: 0

Views: 996

Answers (2)

Littlefoot
Littlefoot

Reputation: 142720

One option might be to multiply number of months (processed_num * periodvalue) with the interval of 1 month and add that to start_billdate:

start_billdate + (interval '1 month' * processed_num * periodvalue);

Upvotes: 2

user330315
user330315

Reputation:

You can construct an interval with the contents of the column:

start_billdate + make_interval(months => processed_num*periodvalue)

Upvotes: 1

Related Questions