Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Tom Lane
Robert Haas writes: > Ooh, I like it. A related personal pet peeve of mine: AFAIK the > easiest way to convert from an integer number of seconds to an > interval representing that many seconds is: > (the_int || ' s')::interval No, the standard solution is the_int * '1 second'::interval

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Robert Haas
On Fri, Oct 22, 2010 at 4:27 PM, Alvaro Herrera wrote: > Excerpts from Alvaro Herrera's message of vie oct 22 17:13:31 -0300 2010: >> Excerpts from Robert Haas's message of vie oct 22 16:54:01 -0300 2010: >> >> > Ooh, I like it.  A related personal pet peeve of mine: AFAIK the >> > easiest way to

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Alvaro Herrera
Excerpts from Alvaro Herrera's message of vie oct 22 17:13:31 -0300 2010: > Excerpts from Robert Haas's message of vie oct 22 16:54:01 -0300 2010: > > > Ooh, I like it. A related personal pet peeve of mine: AFAIK the > > easiest way to convert from an integer number of seconds to an > > interval

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Alvaro Herrera
Excerpts from Robert Haas's message of vie oct 22 16:54:01 -0300 2010: > Ooh, I like it. A related personal pet peeve of mine: AFAIK the > easiest way to convert from an integer number of seconds to an > interval representing that many seconds is: > > (the_int || ' s')::interval > > I guess we

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Robert Haas
On Fri, Oct 22, 2010 at 3:20 PM, Brendan Jurd wrote: > On 23 October 2010 06:15, Josh Berkus wrote: >> a) you'd need to rename these. > > I'm open to that.  What names would you propose? > >> b) we'd also want the inverse of these, which would be extremely useful. > > Not a problem. Ooh, I like

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Brendan Jurd
On 23 October 2010 06:15, Josh Berkus wrote: > a) you'd need to rename these. I'm open to that. What names would you propose? > b) we'd also want the inverse of these, which would be extremely useful. Not a problem. Cheers, BJ -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Josh Berkus
Brendan, > date(year int, month int, day int) returns date > datetime(year int, month int, day int, hour int, minute int, second > int) returns timestamp a) you'd need to rename these. b) we'd also want the inverse of these, which would be extremely useful. > Without these functions (or some var

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Brendan Jurd
On 23 October 2010 05:58, Peter Geoghegan wrote: > On 22 October 2010 19:45, Brendan Jurd wrote: >> Without these functions (or some variation), a user wishing to >> construct a date from integers can only assemble the date into a >> string and then put that string through postgres' datetime pars

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Robert Haas
On Fri, Oct 22, 2010 at 2:45 PM, Brendan Jurd wrote: > date(year int, month int, day int) returns date > datetime(year int, month int, day int, hour int, minute int, second > int) returns timestamp > > Without these functions (or some variation), a user wishing to > construct a date from integers

Re: [HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Peter Geoghegan
On 22 October 2010 19:45, Brendan Jurd wrote: > Hi folks, > > In my own databases, I've been using a couple of C functions that > might be useful to the wider community. > > They are very simple date/timestamp constructors that take integers as > their arguments.  Nothing fancy, but very convenien

[HACKERS] Integer input functions for date and timestamp

2010-10-22 Thread Brendan Jurd
Hi folks, In my own databases, I've been using a couple of C functions that might be useful to the wider community. They are very simple date/timestamp constructors that take integers as their arguments. Nothing fancy, but very convenient and *much* faster than using a SQL or PL/pgSQL workaround