Thread: Timezone template for to_char(timestamp, '...')?

Timezone template for to_char(timestamp, '...')?

From
"Robert B. Easter"
Date:
I'm using

    to_char(timestamp, 'Dy @MM:MIAM, Mon DD, YYYY')

to format a timestamp and its works fine except I'd like to add the timezone
(EDT etc) to the end.

Is there a format template for timezone?  I thought TZ might be it, but it
doesn't work.

The documentation for to_char() is here:
http://www.postgresql.org/docs/postgres/x2976.htm

--
Robert B. Easter

Re: Timezone template for to_char(timestamp, '...')?

From
Karel Zak
Date:
On Thu, 29 Jun 2000, Robert B. Easter wrote:

> I'm using
>
>     to_char(timestamp, 'Dy @MM:MIAM, Mon DD, YYYY')
>
> to format a timestamp and its works fine except I'd like to add the timezone
> (EDT etc) to the end.
>
> Is there a format template for timezone?  I thought TZ might be it, but it
> doesn't work.
>
> The documentation for to_char() is here:
> http://www.postgresql.org/docs/postgres/x2976.htm

 And is anything about TZ in this docs?

 No, to_char() not support timezone (IMHO oracle not support it too), but
support it is not bad idea. I add it to my TODO.

By the way, - current AP/PM code is broken - fix will in new version.

                            Karel


Re: Timezone template for to_char(timestamp, '...')?

From
Thomas Lockhart
Date:
> >       to_char(timestamp, 'Dy @MM:MIAM, Mon DD, YYYY')
> > to format a timestamp and its works fine except I'd like to add the
> > timezone (EDT etc) to the end.

Well, if you *really* need it:

  set datestyle = 'postgres';
  set time zone 'PST8PDT';
  select to_char(timestamp 'now' , 'Dy @MM:MIAM, Mon DD, YYYY')
   || ' '
   || substring(timestamp 'now' from char_length(timestamp 'now')-2);
--------------------------------
 Fri @06:35AM, Jun 30, 2000 PDT
(1 row)

                      - Thomas