Re: [HACKERS] Problem with copying abstimes - Mailing list pgsql-hackers

From aixssd!darrenk@abs.net (Darren King)
Subject Re: [HACKERS] Problem with copying abstimes
Date
Msg-id 773c7fc8f2f8e001e2b82b6d60a34f16
Whole thread Raw
In response to [HACKERS] Problem with copying abstimes  (Ronald Baljeu <rjb@xs4all.nl>)
List pgsql-hackers
> > Postgres needs something like the TO_CHAR(), TO_DATE() and
> > TO_NUMBER() functions for converting and formating the various data types.
>
> Has 'em, or will (see below).

Not quite...TO_CHAR() takes a date and a format string as args and then returns
a char-type of that date formatted according to the given format string.

Ex...

create table foo (bday date);
insert into foo values (TO_DATE('12-FEB-1969','DD-MON-YYYY'));
select TO_CHAR(bday, '"Birthday is" fmMonth ddth, Year') as Birthday from foo;

BIRTHDAY
- ------------------------------------------------------------------------------
Birthday is February 12th, Nineteen Sixty-Nine

I could send you the Oracle docs for the format if you'd like.  They're very
powerful in generating reports or formatting for piping to scripts, etc.

> So,
> neither Oracle nor Ingres are probably the best models for the right way
> to do it, and I suppose Postgres is not trying to become an Oracle
> look-alike but rather a modern, lean, try-to-do-it-the-sensible-way
> system.

Not that I want postgres to be exactly like Oracle, but their date handling
is one of their strong points, IMHO.

> Of course, SQL92 was carefully designed to not break existing databases
> too much, so might have some stuff which is a waste of time. I would
> propose that for v7.0 we migrate to the ANSI SQL date/time terminology,
> and have the existing datetime type migrate to become timestamp, and the
> existing timespan type become interval. date and time would stay defined
> and become more ANSI-like if not so already.

As long as there's one datatype that has both date and time, and there's a
function to format the output of that type, I could live with it.

> abstime has been used since the beginning of (Unix) time in the
> internals of Postgres, but I would suggest that it might be deprecated
> as a user-level type.

Do I hear a vote of doing the same with oid?  I'd better quit while I'm at
least close to even here. :) :)

> Other comments?

Coming from a math theory background, why are people so intent on separating
date and time?  They're both _time_ really... :)  One datatype that contains
both is the only "perfect" date or time type.  (See what happens when I have
too much coffee in the morning? :)

Has anybody ever run the postgres code thru lint?  I thought about it, but
the output could be scrolling for _years_ I'm afraid...

Darren  darrenk@insightdist.com

------------------------------

pgsql-hackers by date:

Previous
From: Frank Dana
Date:
Subject: Re: [HACKERS] Problem with copying abstimes
Next
From: "Sergey V. Lunegov"
Date:
Subject: [HACKERS] subsribe