From: | Juan Pablo L <jpablolorenzetti(at)gmail(dot)com> |
---|---|
To: | Andreas Brandl <ml(at)3(dot)141592654(dot)de> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: replacing expresion in plpgsql |
Date: | 2013-12-16 00:52:51 |
Message-ID: | CABSYDaby9-x3M2Xvd7NDHPGAO6x1t0w7K6Uc6ZwM6ejROi5K4A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi i m working with timestamp cause i need the time too. i tried your
solution and it works perfectly, it just does not adjust to my problem.
thanks a lot for the answer.
On 15 December 2013 18:17, Andreas Brandl <ml(at)3(dot)141592654(dot)de> wrote:
> Hi,
>
> ----- Ursprüngliche Mail -----
> >
> > Hi, i have a function that receives a parameter which represents
> > days:
> >
> >
> > FUNCTION aaa_recharge_account(expdays integer)
> >
> >
> > i want to add those days to the CURRENT_DATE, but i do not know how
> > to do it, i have tried several ways to replace that in an expresion
> > like:
>
> assuming you want to add expdays days to the CURRENT_DATE, you can just
> use + arithmetic of date:
>
> # SELECT CURRENT_DATE + 5 as in_the_future_after_5_days;
> in_the_future_after_5_days
> ----------------------------
> 2013-12-21
> (1 row)
>
> >
> > newexpdate := CURRENT_TIMESTAMP + interval '$1 days' using expdays;
> > (newexpdate is declared as timestamp)
> >
> >
> > and many more but none work, can someone please help me to find out
> > how can i replace that parameter into an expression that i can add
> > to CURRENT_TIMESTAMP or any other way that i can accomplish what i
> > need which is to add that parameter to the current timestamp.
> > thanks!!!
>
> Check this out:
>
> # select current_timestamp, current_timestamp + interval '2' day;
> now | ?column?
> -------------------------------+-------------------------------
> 2013-12-16 01:16:19.783235+01 | 2013-12-18 01:16:19.783235+01
> (1 row)
>
> AFAIK that should also be SQL compliant.
>
> Regards,
> Andreas
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Juan Pablo L | 2013-12-16 00:53:53 | Re: replacing expresion in plpgsql |
Previous Message | John R Pierce | 2013-12-16 00:23:47 | Re: replacing expresion in plpgsql |