Skip site navigation (1) Skip section navigation (2)

date_part()/EXTRACT(second) behaviour with time data type

From: Gregory Stark <stark(at)mit(dot)edu>
To: Postgres <pgsql-hackers(at)postgresql(dot)org>
Subject: date_part()/EXTRACT(second) behaviour with time data type
Date: 2009-07-29 15:15:30
Message-ID: 87ocr31pwt.fsf@oxford.xeocode.com (view raw or flat)
Thread:
Lists: pgsql-hackers
I think we broke date_part for extracting seconds from time arguments. It
appears we leave out the milliseconds whereas we don't for timestamp
arguments. This was not the case in 8.3 where we included the milliseconds for
both data types.

Unless this is intentional? I know we wacked around both the meaning of SECOND
for intervals and the code for date_part in a lot of ways. But I don't see why
it would be different for time versus timestamp.

postgres=# select extract(second from now()::time with time zone);
 date_part 
-----------
        27
(1 row)

postgres=# select extract(second from now()::time without time zone);
 date_part 
-----------
        27
(1 row)

postgres=# select extract(second from now()::timestamp with time zone);
 date_part 
-----------
 27.782458
(1 row)

postgres=# select extract(second from now()::timestamp without time zone);
 date_part 
-----------
 27.782458
(1 row)


-- 
  Gregory Stark
  http://mit.edu/~gsstark/resume.pdf

Responses

pgsql-hackers by date

Next:From: Pavel StehuleDate: 2009-07-29 15:25:53
Subject: Re: plpgsql: support identif%TYPE[], (from ToDo)
Previous:From: Tom LaneDate: 2009-07-29 14:33:58
Subject: Re: Review: Revise parallel pg_restore's scheduling heuristic

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group