Home > Software engineering >  ADD_MONTHS in PostgreSQL
ADD_MONTHS in PostgreSQL

Time:11-23

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?

CodePudding user response:

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);

CodePudding user response:

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

start_billdate   make_interval(months => processed_num*periodvalue)
  • Related