dbTalk Databases Forums  

date_trunc and timezone

comp.databases.postgresql comp.databases.postgresql


Discuss date_trunc and timezone in the comp.databases.postgresql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
news
 
Posts: n/a

Default date_trunc and timezone - 02-17-2010 , 07:55 AM






Hi, does date_trunc return values related to current timezone?

see this:

db_atm=# select extract('epoch' from date_trunc('day',
'epoch'::timestamp + '1234567890 seconds'::interval) at time zone 'CET');
date_part
------------
1234479600
(1 row)

db_atm=# select extract('epoch' from date_trunc('day',
'epoch'::timestamp + '1234567890 seconds'::interval) at time zone 'UTC');
date_part
------------
1234483200
(1 row)

db_atm=# select extract('epoch' from date_trunc('day',
'epoch'::timestamp + '1234567890 seconds'::interval));
date_part
------------
1234479600
(1 row)

it seems it returns date in current timezone even if the imput timestamp
it is without timezone.

Reply With Quote
  #2  
Old   
Mladen Gogala
 
Posts: n/a

Default Re: date_trunc and timezone - 02-17-2010 , 11:25 AM






On Wed, 17 Feb 2010 13:55:46 +0100, news wrote:

Quote:
Hi, does date_trunc return values related to current timezone?
No. It only truncates the given timestamp value to the requested
precision: http://tinyurl.com/yju3snt





--
http://mgogala.byethost5.com

Reply With Quote
  #3  
Old   
news
 
Posts: n/a

Default Re: date_trunc and timezone - 02-18-2010 , 08:11 AM



Il 17/02/2010 17.25, Mladen Gogala ha scritto:
Quote:
On Wed, 17 Feb 2010 13:55:46 +0100, news wrote:

Hi, does date_trunc return values related to current timezone?

No. It only truncates the given timestamp value to the requested
precision: http://tinyurl.com/yju3snt
You right, the source of my problems it is extract:

db_atm=# select 'epoch'::timestamp + '1234567890 seconds'::interval;
?column?
---------------------
2009-02-13 23:31:30
(1 row)

db_atm=# select extract('epoch' from 'epoch'::timestamp + '1234567890
seconds'::interval);
date_part
------------
1234564290
(1 row)

db_atm=# select extract('epoch' from ('epoch'::timestamp + '1234567890
seconds'::interval) at time zone 'UTC');
date_part
------------
1234567890
(1 row)

db_atm=# select date_trunc('minute', 'epoch'::timestamp + '1234567890
seconds'::interval);
date_trunc
---------------------
2009-02-13 23:31:00
(1 row)

db_atm=# select date_trunc('minute', ('epoch'::timestamp + '1234567890
seconds'::interval) at time zone 'UTC');
date_trunc
------------------------
2009-02-14 00:31:00+01
(1 row)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.