Thread: make_interval ??
Hello
we have defined interface date, time, timestamp constructors.and usage:
Pavel, > So constructor should to look like: > > CREATE OR REPLACE FUNCTION make_interval(years int DEFAULT 0, months int > DEFAULT 0, ...) > > and usage: > > SELECT make_interval(years := 2) > SELECT make_interval(days := 14) > > Is there a interest for this (or similar) function? It would certainly make our Python users happy. And for that matter would get rid of this kind of stupid thing in stored procedure code: time_ahead := ( interval '1 minute' * var_skip ); So, +1 for the feature. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com
On 21/12/13 06:29, Josh Berkus wrote: > Pavel, > >> So constructor should to look like: >> >> CREATE OR REPLACE FUNCTION make_interval(years int DEFAULT 0, months int >> DEFAULT 0, ...) >> >> and usage: >> >> SELECT make_interval(years := 2) >> SELECT make_interval(days := 14) >> >> Is there a interest for this (or similar) function? > It would certainly make our Python users happy. > > And for that matter would get rid of this kind of stupid thing in stored > procedure code: > > time_ahead := ( interval '1 minute' * var_skip ); > > So, +1 for the feature. > What about leap years? Cheers, Gavin
On 12/20/2013 03:09 PM, Gavin Flower wrote: > What about leap years? What about them? -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com
On 21/12/13 13:40, Josh Berkus wrote: > On 12/20/2013 03:09 PM, Gavin Flower wrote: >> What about leap years? > What about them? > some years have 365 days others have 366, so how any days in an interval of 2 years?, 4 years?
On 12/20/2013 04:44 PM, Gavin Flower wrote: > On 21/12/13 13:40, Josh Berkus wrote: >> On 12/20/2013 03:09 PM, Gavin Flower wrote: >>> What about leap years? >> What about them? >> > some years have 365 days others have 366, so how any days in an interval > of 2 years?, 4 years? Your question isn't relevant to this patch. It's not defining the interval type, just creating an alternate constructor for it. (the answer is, it depends on what timestamp you're adding it to ...) -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com
Hello
here is patchpostgres=# select make_interval(years := 1, months := 6);
make_interval
---------------
1 year 6 mons
(1 row)
postgres=# select make_interval(weeks := 3);
make_interval
---------------
21 days
(1 row)
postgres=# select make_interval(days := 10);
make_interval
---------------
10 days
(1 row)
postgres=# select make_interval(hours := 2, mins := 10, secs := 25.33);
make_interval
---------------
02:10:25.33
(1 row)
2013/12/21 Josh Berkus <josh@agliodbs.com>
On 12/20/2013 04:44 PM, Gavin Flower wrote:Your question isn't relevant to this patch. It's not defining the
> On 21/12/13 13:40, Josh Berkus wrote:
>> On 12/20/2013 03:09 PM, Gavin Flower wrote:
>>> What about leap years?
>> What about them?
>>
> some years have 365 days others have 366, so how any days in an interval
> of 2 years?, 4 years?
interval type, just creating an alternate constructor for it.
(the answer is, it depends on what timestamp you're adding it to ...)--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers