Re: fixes for date_part micro/millisecond precision - Mailing list pgsql-patches

From Karel Zak
Subject Re: fixes for date_part micro/millisecond precision
Date
Msg-id 20011126133821.E10818@zf.jcu.cz
Whole thread Raw
In response to Re: fixes for date_part micro/millisecond precision  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: fixes for date_part micro/millisecond precision
List pgsql-patches
On Sat, Nov 24, 2001 at 02:24:09PM -0500, Tom Lane wrote:
> Brent Verner <brent@rcfile.org> writes:
> >   This patch fixes a problem where extract/date_part returns bad values
> > for microsecond and millisecond parts.
>
> I'm not convinced the existing behavior is wrong.  Timestamps are floats
> in PG, and therefore not infinitely precise.  Your patch seems to be
> trying to cover this up, but I fear it will only succeed in introducing
> other problems.

 Tom is right. If you need non-float microsecond/millisecond you can
 use to_char() -- it's news in 7.2:

test=# select to_char('2001-11-24 13:49:12.826833-05'::timestamp, 'MS');
 to_char
---------
   827

test=# select to_char('2001-11-24 13:49:12.826833-05'::timestamp, 'US');
 to_char
---------
 826833

        Karel

--
 Karel Zak  <zakkr@zf.jcu.cz>
 http://home.zf.jcu.cz/~zakkr/

 C, PostgreSQL, PHP, WWW, http://docs.linux.cz, http://mape.jcu.cz

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Added Encoding
Next
From: Weiping He
Date:
Subject: Re: Chinese NLS patch, the third try.