Re: [HACKERS] Inputting relative datetimes

2011-08-31 Thread Dean Rasheed
On 30 August 2011 16:40, Robert Haas wrote: > OK, committed. Thanks. I'm fine with not back-patching it, on the grounds given. Cheers, Dean -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hack

Re: [HACKERS] Inputting relative datetimes

2011-08-30 Thread Tom Lane
Robert Haas writes: > Well, I'm fine with not back-patching it, but think the existing > behavior is flat wrong. I'm not arguing that this way isn't better, just that it's different. There have been zero user complaints about this behavior since Tom Lockhart put it in, more than ten years ago. T

Re: [HACKERS] Inputting relative datetimes

2011-08-30 Thread Robert Haas
On Tue, Aug 30, 2011 at 11:52 AM, Tom Lane wrote: > Robert Haas writes: >> On Sun, Aug 28, 2011 at 5:39 AM, Dean Rasheed >> wrote: >>> The attached patch makes "today", "tomorrow" and "yesterday" only set >>> the year, month and day fields. All the other fields are already >>> initialised to 0

Re: [HACKERS] Inputting relative datetimes

2011-08-30 Thread Tom Lane
Robert Haas writes: > On Sun, Aug 28, 2011 at 5:39 AM, Dean Rasheed > wrote: >> The attached patch makes "today", "tomorrow" and "yesterday" only set >> the year, month and day fields. All the other fields are already >> initialised to 0 at the start, and may be set non-zero before or after >> e

Re: [HACKERS] Inputting relative datetimes

2011-08-30 Thread Robert Haas
On Sun, Aug 28, 2011 at 5:39 AM, Dean Rasheed wrote: > On 28 August 2011 00:39, Robert Haas wrote: >> On Sat, Aug 27, 2011 at 7:43 AM, Dean Rasheed >> wrote: >>> On 27 August 2011 12:29, Dean Rasheed wrote: ... if nothing else it has been a fun exercise figuring out how the datetime

Re: [HACKERS] Inputting relative datetimes

2011-08-28 Thread Dean Rasheed
On 28 August 2011 00:00, Jeff MacDonald wrote: > Greetings, > > On Saturday, August 27, 2011 11:36:13 AM Dean Rasheed wrote: >> >> I'm not sure how best to handle timezones though, since it's >> hard-coded list probably won't match the timezones PostgreSQL knows >> about. Maybe that doesn't matter

Re: [HACKERS] Inputting relative datetimes

2011-08-28 Thread Dean Rasheed
On 28 August 2011 00:39, Robert Haas wrote: > On Sat, Aug 27, 2011 at 7:43 AM, Dean Rasheed > wrote: >> On 27 August 2011 12:29, Dean Rasheed wrote: >>> ... if nothing else it has been a >>> fun exercise figuring out how the datetime string parsing code works. >> >> While looking through the cu

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Robert Haas
On Sat, Aug 27, 2011 at 7:43 AM, Dean Rasheed wrote: > On 27 August 2011 12:29, Dean Rasheed wrote: >> ... if nothing else it has been a >> fun exercise figuring out how the datetime string parsing code works. > > While looking through the current code, I spotted the following oddity: > > select

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Jeff MacDonald
Greetings, On Saturday, August 27, 2011 11:36:13 AM Dean Rasheed wrote: > > I'm not sure how best to handle timezones though, since it's > hard-coded list probably won't match the timezones PostgreSQL knows > about. Maybe that doesn't matter, I'm not sure. > It'll matter when the expression has

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Dean Rasheed
On 27 August 2011 14:29, Jeff MacDonald wrote: > Greetings, > > On Thursday, August 25, 2011 05:39:09 AM Dean Rasheed wrote: >> As background, I have an app that accepts user text input and casts it >> to a timestamp in order to produce reports. I use PostgreSQL's >> timestamp input conversion for

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Dean Rasheed
On 27 August 2011 14:14, Peter Eisentraut wrote: > On lör, 2011-08-27 at 12:29 +0100, Dean Rasheed wrote: >> So Robert and Merlin both expressed concerns that the existing >> datetime string parsing code is so complicated that adding to it would >> likely just introduce more bugs. >> >> My first t

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Jeff MacDonald
Greetings, On Thursday, August 25, 2011 05:39:09 AM Dean Rasheed wrote: > As background, I have an app that accepts user text input and casts it > to a timestamp in order to produce reports. I use PostgreSQL's > timestamp input conversion for this, since it gives a lot of > flexibility, and can pa

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Peter Eisentraut
On lör, 2011-08-27 at 12:29 +0100, Dean Rasheed wrote: > So Robert and Merlin both expressed concerns that the existing > datetime string parsing code is so complicated that adding to it would > likely just introduce more bugs. > > My first thought was 'how hard can it be?' - famous last words :-)

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Dean Rasheed
On 27 August 2011 12:29, Dean Rasheed wrote: > ... if nothing else it has been a > fun exercise figuring out how the datetime string parsing code works. > While looking through the current code, I spotted the following oddity: select timestamp 'yesterday 10:30'; timestamp -

Re: [HACKERS] Inputting relative datetimes

2011-08-27 Thread Dean Rasheed
On 27 August 2011 02:32, Robert Haas wrote: > Frankly, our current date parsing code is pretty darn strange and > flaky... So Robert and Merlin both expressed concerns that the existing datetime string parsing code is so complicated that adding to it would likely just introduce more bugs. My fir

Re: [HACKERS] Inputting relative datetimes

2011-08-26 Thread Robert Haas
On Fri, Aug 26, 2011 at 4:32 PM, Jim Nasby wrote: > On Aug 25, 2011, at 5:08 AM, Dean Rasheed wrote: >>> 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 enter

Re: [HACKERS] Inputting relative datetimes

2011-08-26 Thread Jim Nasby
On Aug 25, 2011, at 5:08 AM, Dean Rasheed wrote: >> 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

Re: [HACKERS] Inputting relative datetimes

2011-08-25 Thread Josh Berkus
> 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. I think adding a function would be the way to go then. Maybe extending to_time

Re: [HACKERS] Inputting relative datetimes

2011-08-25 Thread Merlin Moncure
On Thu, Aug 25, 2011 at 5:08 AM, Dean Rasheed wrote: > On 25 August 2011 10:43, Vik Reykja wrote: >> On Thu, Aug 25, 2011 at 11:39, Dean Rasheed >> 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 addin

Re: [HACKERS] Inputting relative datetimes

2011-08-25 Thread Dean Rasheed
On 25 August 2011 10:43, Vik Reykja wrote: > On Thu, Aug 25, 2011 at 11:39, Dean Rasheed > 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 " and "minus ".

Re: [HACKERS] Inputting relative datetimes

2011-08-25 Thread Vik Reykja
On Thu, Aug 25, 2011 at 11:39, Dean Rasheed 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 " and "minus ". > This would allow things like: > > TIMESTAMPTZ 'toda

[HACKERS] Inputting relative datetimes

2011-08-25 Thread Dean Rasheed
As background, I have an app that accepts user text input and casts it to a timestamp in order to produce reports. I use PostgreSQL's timestamp input conversion for this, since it gives a lot of flexibility, and can parse pretty much anything the users throw at it. It is also handy that it recogni