From: | Brendan Jurd <direvus(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Integer input functions for date and timestamp |
Date: | 2010-10-22 18:45:07 |
Message-ID: | AANLkTi=W1wtcL7qR4PuQaQ=UoabmjSUSz6QGJTUCXF-P@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
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.
The offering is analogous to mktime() in C/PHP, the standard datetime
constructors in Python, and Perl's Time::Local. The function
signatures pretty much speak for themselves:
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 can only assemble the date into a
string and then put that string through postgres' datetime parser,
which is totally perverse.
Is there any interest in adding this to core, or failing that,
contrib? If so I'd be happy to provide a patch including the
functions themselves and some attendant documentation.
I'm not wedded to the function names or argument order, and I realise
a fully realised offering would need to include a variant for
'timestamp with time zone'.
Cheers,
BJ
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2010-10-22 18:58:29 | Re: Integer input functions for date and timestamp |
Previous Message | Alvaro Herrera | 2010-10-22 18:35:52 | Re: Extensions, this time with a patch |