value returned by EXTRACT, date_part - Mailing list pgsql-sql

From John Lumby
Subject value returned by EXTRACT, date_part
Date
Msg-id DM6PR06MB5562115198C798B1C06B32DBA3520@DM6PR06MB5562.namprd06.prod.outlook.com
Whole thread Raw
Responses Re: value returned by EXTRACT, date_part  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-sql
I notice that although EXTRACT(field FROM source) returns a value of 
type double-precision,

for some field types,  it apparently rounds the value to an integer,   
(even though the exact value is not integral),

whereas for others it returns the exact value including any fractional 
part un-rounded. Examples can be seen in the book :


SELECT EXTRACT(DAY FROM INTERVAL '40 days 1 minute');
Result: 40

rounded down from 40.0.0006944444444444445


SELECT EXTRACT(EPOCH FROM TIMESTAMP WITH TIME ZONE '2001-02-16 
20:38:40.12-08');
Result: 982384720.12

un-rounded


This seems inconsistent to me - and undocumented as far as I can tell.

Is there any reason for this?    And can it be relied on in programs?


Cheers,   John




pgsql-sql by date:

Previous
From: Mike Martin
Date:
Subject: Stored procedure and returning clause
Next
From: "David G. Johnston"
Date:
Subject: Re: value returned by EXTRACT, date_part