Re: timestamp format bug

From: "Roberts, Jon" <Jon(dot)Roberts(at)asurion(dot)com>
To: 'Kevin Grittner' <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp format bug
Date: 2008-01-31 18:28:04
Message-ID: 1A6E6D554222284AB25ABE3229A92762715525@nrtexcus702.int.asurion.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> -----Original Message-----
> From: Kevin Grittner [mailto:Kevin(dot)Grittner(at)wicourts(dot)gov]
> Sent: Thursday, January 31, 2008 9:48 AM
> To: Roberts, Jon; pgsql-hackers(at)postgresql(dot)org
> Subject: Re: [HACKERS] timestamp format bug
>
> >>> On Thu, Jan 31, 2008 at 9:34 AM, in message
> <1A6E6D554222284AB25ABE3229A92762715521(at)nrtexcus702(dot)int(dot)asurion(dot)com>,
> "Roberts,
> Jon" <Jon(dot)Roberts(at)asurion(dot)com> wrote:
> > select to_char(date, 'yyyy-mm-dd hh24:mi:ss.ms') as char,
> > date
> > from (select timestamp'2008-01-30 15:06:21.560' as date) sub
> >
> > "2008-01-30 15:06:21.560";"2008-01-30 15:06:21.56"
> >
> > These two fields should be consistent because they should be formatted
> > the same way.
>
> Why would you think that?
>
> I would expect the timestamp to be presented with one to nine
> digits to the right of the decimal point, depending on the value.

I expect the query to return either:
"2008-01-30 15:06:21.560";"2008-01-30 15:06:21.560"

or:
"2008-01-30 15:06:21.56";"2008-01-30 15:06:21.56"

The default timestamp format appears to be yyyy-mm-dd hh24:mi:ss.ms but it
doesn't follow this for milliseconds. It truncates the trailing zero for
timestamps and it does not truncate the trailing zero when cast as a
character.

I don't care which standard should be adopted but it should be the same.

>
> I can think of a couple database products which only go to three
> decimal positions, and always show three, but that's hardly a
> standard.

Oracle and MS SQL Server are consistent in this.

Jon

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2008-01-31 18:32:50 Re: timestamp format bug
Previous Message Bruce Momjian 2008-01-31 17:32:46 Re: [HACKERS] SSL over Unix-domain sockets