Re: Getting 2002-12-18T17:32:40-05:00 (ISO 8601) from

From: Karl DeBisschop <kdebisschop(at)alert(dot)infoplease(dot)com>
To: Peter Gibbs <peter(at)emkel(dot)co(dot)za>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Getting 2002-12-18T17:32:40-05:00 (ISO 8601) from
Date: 2002-12-19 16:04:17
Message-ID: 1040313856.7570.8.camel@skillet.infoplease.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 2002-12-19 at 10:28, Peter Gibbs wrote:
> Karl DeBisschop wrote:
>
> > I'd like to get an ISO 8601 date from postgresql in the following form:
> >
> > 2002-12-18T17:26:04-05:00
> >
> > Second is the 'T' after the date part (where you might otherwise have a
> > space).
>
> Quote from the docs:
> Ordinary text is allowed in to_char templates and will be output literally.
> You can put a substring in double quotes to force it to be interpreted as
> literal text even if it contains pattern keywords. For example, in '"Hello
> Year: "YYYY', the YYYY will be replaced by year data, but the single Y will
> not be.
>
> So, try
> # select to_char(now(),'YYYY-MM-DD"T"HH24:MI:SS');
>
> --
> Peter Gibbs
> EmKel Systems

Thanks very much. I read the docs 3 or 4 times, but must have developed
a blind spot to that passage.

As one might expect, to_char does exactly what is says it does, and your
solution works perfectly.

No bites on the offset from UTC yet, but this definitely cleans up some
code.

--
Karl DeBisschop <kdebisschop(at)alert(dot)infoplease(dot)com>
Pearson Education/Information Please

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jean-Luc Lachance 2002-12-19 16:08:46 Re: ORDER BY random() LIMIT 1 slowness
Previous Message Manfred Koizar 2002-12-19 15:56:11 Re: IN or EXISTS?? faster one