Re: proposal: simple date constructor from numeric values - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: proposal: simple date constructor from numeric values
Date
Msg-id CAFj8pRDYNQ9O1S3bUy2N_ZHGfvJKCtTq3=5ox0dhmcdV6bRhTA@mail.gmail.com
Whole thread Raw
In response to Re: proposal: simple date constructor from numeric values  (Brendan Jurd <direvus@gmail.com>)
Responses Re: proposal: simple date constructor from numeric values
List pgsql-hackers
Hello

2013/7/3 Brendan Jurd <direvus@gmail.com>:
> On 1 July 2013 17:47, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>> 2013/6/29 Pavel Stehule <pavel.stehule@gmail.com>:
>>> long time I am thinking about simple function for creating date or
>>> timestamp values based on numeric types without necessity to create
>>> format string.
>>>
>>> What do you think about this idea?
>> I found so same idea was discussed three years ago
>>
>> http://www.postgresql.org/message-id/14107.1276443739@sss.pgh.pa.us
>>
>
> I suggested something similar also:
>
> http://www.postgresql.org/message-id/AANLkTi=W1wtcL7qR4PuQaQ=UoabmjSUSz6QGJTUCXF-P@mail.gmail.com
>
> The thread I linked died off without reaching a consensus about what
> the functions ought to be named, although Josh and Robert were
> generally supportive of the idea.
>
> The function signatures I have been using in my own C functions are:
>
> * date(year int, month int, day int) returns date
> * datetime(year int, month int, day int, hour int, minute int, second
> int) returns timestamp
>

I am thinking so for these functions exists some consensus - minimally
for function "date"(year, month, int) - I dream about this function
ten years :)

I am not sure about "datetime":

a) we use "timestamp" name for same thing in pg
b) we can simply construct timestamp as sum of date + time, what is
little bit more practical (for me), because it doesn't use too wide
parameter list.

so my proposal is two new function "date" and "time"

but, because we doesn't support type constructor function, I don't
think so name "date" is good (in this moment)

MSSQL has function DATEFROMPARTS, TIMEFROMPARTS and DATETIMEFROMPARTS
MySQL has little bit obscure function MAKEDATE(year, dayinyear) and
MAKETIME(hour, min, sec)
Oracle and db2 has nothing similar

what do you think about names?

make_date
make_time

I don't would to use to_date, to_time functions, a) because these
functions use formatted input, b) we hold some compatibility with
Oracle.

Regards

Pavel Stehule



>
> Cheers,
> BJ



pgsql-hackers by date:

Previous
From: Nikhil Sontakke
Date:
Subject: Re: Custom gucs visibility
Next
From: Noah Misch
Date:
Subject: Re: proposal: enable new error fields in plpgsql (9.4)