Search Postgresql Archives

Re: strange TIME behaviour

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Michael Fuhr wrote:
On Sat, Sep 15, 2007 at 04:45:02PM +0500, rihad wrote:
Can someone please explain to me why these two give different results? The idea is to get the number of seconds past 00:00:00, so the second one is obviously correct.

They're both correct.

foo=> select extract(epoch from current_time);
  date_part
--------------
 42023.026348
(1 row)

current_time is a time with time zone; the above query returns the
number of seconds since 00:00:00 UTC.

foo=> select extract(epoch from cast(current_time as time));
  date_part
--------------
 60030.824587
(1 row)

By casting current_time to time without time zone you're now getting
the number of seconds since 00:00:00 in your local time zone.




I'm reading this right now: http://www.postgresql.org/docs/8.2/interactive/datatype-datetime.html "time with time zone" is not recommended. I'm still unsure if the timezone issue is at all important when comparing timestamps (greater/less/etc), or when adding intervals to preset dates? Like registration_time + interval '2 months';

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux