Re: Declare variable from other variable

2020-02-05 Thread Raul Kaubi
Makes sense yeah. Thanks for both of your help. Raul Kontakt hubert depesz lubaczewski () kirjutas kuupäeval K, 5. veebruar 2020 kell 14:50: > On Wed, Feb 05, 2020 at 02:42:42PM +0200, Raul Kaubi wrote: > > Thanks, it worked! > > > > By the way, what does this "**j"* mean there..? (this does no

Re: Declare variable from other variable

2020-02-05 Thread hubert depesz lubaczewski
On Wed, Feb 05, 2020 at 02:42:42PM +0200, Raul Kaubi wrote: > Thanks, it worked! > > By the way, what does this "**j"* mean there..? (this does not mean > multiply there?) it's normal multiplication. Your "j" variable is integer. So, '1 month'::interval * j is some number of months. > And what

Re: Declare variable from other variable

2020-02-05 Thread Raul Kaubi
Thanks, it worked! By the way, what does this "**j"* mean there..? (this does not mean multiply there?) And what if, I would like to declare v_to_date also, so that v_to_date is always + 1 month compared to v_date_from..? -- This one will work, but can this be done simpler..? v_to_date := (date_

Re: Declare variable from other variable

2020-02-05 Thread Thomas Kellerer
Raul Kaubi schrieb am 05.02.2020 um 12:21: > How can I declare another variable from another variable. > Basically from oracle, I can just:  > > var1 := 'asda'||var2; > > In postgres, I have the following example, I would like to use variable j to > add number of months there. > > " interv

Re: Declare variable from other variable

2020-02-05 Thread Yasin Sari
On Wed, Feb 5, 2020 at 2:22 PM Raul Kaubi wrote: > > DO $$ >> DECLARE >> v_var integer := 1; >> v_from_date date; >> BEGIN >> for j in 0..v_var LOOP >> v_from_date := (date_trunc('month',current_date) + interval 'j >> month')::date; >> RAISE NOTICE '%', v_from_date; >> END LOOP; >> END; >> $$ LAN