Re: Inputting relative datetimes

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Vik Reykja <vikreykja(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Inputting relative datetimes
Date: 2011-08-25 21:35:54
Message-ID: CAHyXU0z=qzMBN7PitjBq-Efg9rBOCUeACfveP-RZaLKU9wczLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 25, 2011 at 5:08 AM, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> wrote:
> On 25 August 2011 10:43, Vik Reykja <vikreykja(at)gmail(dot)com> wrote:
>> On Thu, Aug 25, 2011 at 11:39, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
>> wrote:
>>>
>>> My first thought was to have some general way of adding or subtracting
>>> an interval at the end of an input timestamp, eg. by adding another
>>> couple of special values - "plus <interval>" and "minus <interval>".
>>> This would allow things like:
>>>
>>> TIMESTAMPTZ 'today minus 5 days'
>>> TIMESTAMPTZ 'now plus 2 hours'
>>
>> Funny you should mention intervals...
>>
>> timestamptz 'today' - interval '5 days'
>> timestamptz 'now' + interval '2 hours'
>>
>
> Yes, but what I am trying to achieve is a way of entering such
> relative timestamps using a single input value, so that absolute and
> relative timestamps can both be bound to a SQL query using just one
> variable.

not gonna happen. as noted, intervals already solve the issue quite
well and timestamp string parsing is already complicated enough as it
is.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2011-08-25 21:45:15 Re: Buffering GiST leaf pages too
Previous Message Andrew Dunstan 2011-08-25 21:29:54 Re: A couple of issues with psql variable substitution