Search Postgresql Archives

Re: help replacing expresion in plpgsql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Juan Pablo L wrote:
> 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:
> 
> 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!!!

There are many ways.
Two I can think of right away:

newexpdate := CURRENT_TIMESTAMP + CAST(expdays || ' days' AS interval);

newexpdate := CURRENT_TIMESTAMP + expdays * INTERVAL '1 days';

Yours,
Laurenz Albe

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux