Re: Passing varchar parameter to INTERVAL

From: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
To:
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Passing varchar parameter to INTERVAL
Date: 2016-09-07 13:40:15
Message-ID: CAADeyWi0q9p4-GXX3nopRXnAsn+BknOnXk+vH+U4UZTbt8eTGQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello Rob,

On Wed, Sep 7, 2016 at 3:24 PM, rob stone <floriparob(at)gmail(dot)com> wrote:

>
> I think the interval values need to be quoted.
> In any event I always use the P or T syntax. 'P1D' means add one day,
>

unfortunately, I can not call INTERVAL 'in_until', that wouldn't work.

Also 'P1D' vs. '1 day' seems to be just a matter of taste.

Finally, to provide more context to my question -

I would prefer to call my custom function as

select words_ban_user(1, '1 day', 'attacking other users');

and not as

select words_ban_user(1, CURRENT_TIMESTAMP + '1 day', 'attacking other
users');

because additionally to the temporary ban I would like to prolong
VIP-periods for paying users (to avoid discussions) - and that would be
more difficult in the latter case (would require more date acrobatics)...

Regards
Alex

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Attila Soki 2016-09-07 13:41:45 Re: pgadmin4 rc1 query tool performance
Previous Message hubert depesz lubaczewski 2016-09-07 13:35:02 Re: Passing varchar parameter to INTERVAL