Re: EPCOH: extract returns millisecs too?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: EPCOH: extract returns millisecs too?
Date: 2002-08-15 05:00:05
Message-ID: 19966.1029387605@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jean-Christian Imbeault <jc(at)mega-bucks(dot)co(dot)jp> writes:
> [ the docs state ]

> SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
> Result: 982352320

Sure, that is an exact-second timestamp; it's not going to have any
fractional-second component.

> But if I seem to get milliseconds too in my queries:

> $ psql sessions -c "SELECT EXTRACT(EPOCH FROM current_timestamp) as now"
> now
> ------------------
> 1029298563.74248
> (1 row)

> Are the Docs out of date? How can I get EXTRACT to only return seconds?

We return fractional seconds in current_timestamp since 7.2. You can
use current_timestamp(0) to round the result to seconds, or just apply
round() to EXTRACT's result.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Hans Meyer 2002-08-15 08:46:17 DB2->PostgreSQL question on user permissions and views
Previous Message Jean-Christian Imbeault 2002-08-15 04:22:15 EPCOH: extract returns millisecs too?