pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kjetil Nygård <polpot78@gmail.com>
To: PostgreSQL mailing lists <pgsql-jdbc@postgresql.org>
To: pgsql-bugs@postgresql.org
Subject: Timezone error when casting. Maybe daylight saving
Date: Tue, 01 Apr 2014 22:18:34 +0200
Message-ID: <1396383514.15479.13.camel@kjetil.kny.im> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>


I try to build with the tests, but when I run the test
org.postgresql.test.jdbc2.StatementTest.testDateFunctions() i get:
junit.framework.AssertionFailedError: expected:<-3> but was:<-2>


When I run the same function directly in PostgreSQL, I also get -2:

test=> select extract( day from ((CAST(-3 || ' day' as
interval)+now())-now()));
 date_part 
-----------
        -2


When I remove the extract day from the expression, I get:
test=> select  CAST(-3 || ' day' as interval)+now()-now();
     ?column?      
-------------------
 -2 days -23:00:00


Also note these two:

test=> select '3 day'::interval + now();
           ?column?            
-------------------------------
 2014-04-04 22:13:36.144756+02

test=> select  (CAST(-3 || ' days' as interval)+now());
           ?column?            
-------------------------------
 2014-03-29 22:13:38.880739+01


Which should give the same timezone, but they are in +01 and +02.

This seems like a timezone problem, but I do not yet fully understand
why. My timezone is "Europe/Oslo". My PostgreSQL version is 9.3.4, from
PostgreSQL's YUM-repo.


PS: I sent this to both bugs and pgjdbc as it is a bug in PostgreSQL and
affects pgjdbc.


Regards,

Kjetil Nygård
Phone: +47 41 47 43 37





-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (5+ messages)  latest in thread

Message-ID: <1396383514.15479.13.camel@kjetil.kny.im>
Permalink:  ../1396383514.15479.13.camel@kjetil.kny.im/
Also on:    postgresql.org/message-id/1396383514.15479.13.camel@kjetil.kny.im

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: polpot78@gmail.com, pgsql-bugs@postgresql.org
  Subject: Re: Timezone error when casting. Maybe daylight saving
  In-Reply-To: <1396383514.15479.13.camel@kjetil.kny.im>
  References: <1396383514.15479.13.camel@kjetil.kny.im>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox