Re: Postgres RFC3339 datetime formatting

From: Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "'Jasim Mohd *EXTERN*'" <hello(at)jasimmk(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgres RFC3339 datetime formatting
Date: 2016-05-10 16:29:22
Message-ID: A737B7A37273E048B164557ADEF4A58B5384D8EA@ntex2010i.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jasim Mohd wrote:
> Is there any way to format datetime to RFC3339Nano Eg: 2006-01-02T15:04:05.999999999Z07:00 in postgres
> 9.3 or 9.5?
>
> I tried with to_char. But there is no documentation how to handle T, Z, +07:00, -07:00 etc.

The best I can get is:

SELECT to_char(current_timestamp, 'FXYYYY-MM-DD"T"HH:MI:SS.US"000Z"OF');

but it will suppress the minute part of the time zone offset if it is 0.

I don't think you can get nanosecond precision in PostgreSQL.

Is that good enough?

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message John McKown 2016-05-10 16:43:53 Re: Postgres RFC3339 datetime formatting
Previous Message Edson Richter 2016-05-10 16:26:13 Re: Increased I/O / Writes