Re: Declare variable from other variable
От | Raul Kaubi |
---|---|
Тема | Re: Declare variable from other variable |
Дата | |
Msg-id | CAO_+3-CEM0_GTqYxYVFLKenJjzn+K=BqBLur2jx5hH_1SCZUgA@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Declare variable from other variable (Yasin Sari <yasinsari81@googlemail.com>) |
Ответы |
Re: Declare variable from other variable
|
Список | pgsql-general |
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_trunc('month',current_date)::date + interval '1 month' + interval '1 month'*j)::date;
Raul
Kontakt Yasin Sari (<yasinsari81@googlemail.com>) kirjutas kuupäeval K, 5. veebruar 2020 kell 14:28:
On Wed, Feb 5, 2020 at 2:22 PM Raul Kaubi <raulkaubi@gmail.com> 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;
$$ LANGUAGE plpgsql;
ERROR: invalid input syntax for type interval: "j month"
LINE 1: ...LECT (date_trunc('month',current_date) + interval 'j month')...If you replace red line with this one it will work:v_from_date := (date_trunc('month',current_date) + interval '1 month'*j)::date;
В списке pgsql-general по дате отправления: