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 6d57d84add060b3e5b56dc6d707ba077
Whole thread Raw
In response to [HACKERS] Problem with copying abstimes  (Ronald Baljeu <rjb@xs4all.nl>)
List pgsql-hackers
> > 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.
> > 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
>
> May be possible for v6.2. Lousy function names, though, wrt other
> Postgres name conventions... So, TO_DATE() and TO_CHAR() are symmetric,
> so that you can do the following (?):
>
> select TO_CHAR(
>  TO_DATE('12-FEB-1969','"Birthday is" fmMonth ddth, Year'),
>  '"Birthday is" fmMonth ddth, Year');

Almost...

select TO_CHAR(          +----------+   <<--
  TO_DATE('12-FEB-1969','DD-MON-YYYY'),
  '"Birthday is" fmMonth ddth, Year') from DUAL;

The format string to the TO_DATE tells it how to parse the string and then the
format string to TO_CHAR tells it how to print out the now date-type arg.

Notice the "from DUAL"...Oracle requires that you have a FROM clause, so they
have a table called DUAL with one field, DUMMY as a varchar2(1).  Not really
important what is in DUMMY, just that the DUAL table exists, but on the copy
of personal oracle I have, DUMMY is a 'X'.  Their way of letting you select
literals.

Is it in sql-92 if a "FROM" clause is required?

> > Not that I want postgres to be exactly like Oracle, but their date handling
> > is one of their strong points, IMHO.
>
> Boy, add some features and people get _so_ demanding :)
> The first step was adding date/time types which are robust and general
> enough to build on (datetime and timespan are, I believe). The next step
> is to add functionality, so keep those suggestions coming.

I agree about the first step and do appreciate the work/development you've done so far.

One of the great things about postgres is that the developers are free to put in
what they want, how they want and can try to copy/improve on the "best" things from
the commercial dbs or their own ideas.  Sort of like a mongrel winning a dog show.
Might not be "pretty", but it has the best features of all the other dogs there. :)
Not that I'm calling postgres an "ugly mongrel" either...to the contrary...

Darren  darrenk@insightdist.com

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

pgsql-hackers by date:

Previous
From: "Thomas G. Lockhart"
Date:
Subject: Re: [HACKERS] Problem with copying abstimes
Next
From: Brian Schaffner
Date:
Subject: [HACKERS] text field ranking functions