# Bug: Wrong display of Date and Time fields read from Postgresql

**URL:** <https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691>\
**Category:** KNIME Analytics Platform\
**Created:** [May 21, 2013, 12:01pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691 "2013-05-21T12:01:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rd0002](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@rd0002](https://forum.knime.com/u/rd0002)\
**Post date:** [May 21, 2013, 12:01pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/1 "2013-05-21T12:01:05Z")

</div>

(If this is not the right place to report bugs, please correct me)

&nbsp;

The contents of DATE and TIME fields read from Postgresql are displayed wrong.

&nbsp;

System: Linux Fedora Core 18 - 64bit

KNIME: 2.7.4

Postgresql: 9.2.4

JDBC driver:&nbsp;postgresql-9.2-1002.jdbc3.jar

&nbsp;

**Table:**

CREATE TABLE "EQ\_NEIC"  
 (  
 "EQDATE" date,  
 "EQTIME" time without time zone,  
 );

&nbsp;

&nbsp;

**Nodes where seen:**

a) "Database Reader"

b) Combination of&nbsp;"Database Reader" and "Cache"

c) Combination of "Database Connector" and "Database Connection Reader"

&nbsp;

**Query:**

```
select  
"EQDATE",  
"EQTIME"

from "EQ\_NEIC"  
where  
"EQDATE" = ' **2011-03-15**'  
and "EQTIME" \>= ' **08:00:00**'::TIME  
and "EQTIME" \< ' **09:00:00**'::TIME

order by  
"EQDATE",  
"EQTIME"
```

&nbsp;

**Results in Postgresql:**

```
EQDATE | EQTIME  
------------±------------  
2011-03-15 | 08:01:43.76  
2011-03-15 | 08:08:37.08  
2011-03-15 | 08:11:47.7  
2011-03-15 | 08:13:50.1  
2011-03-15 | 08:16:59.52  
2011-03-15 | 08:28:25.71  
2011-03-15 | 08:36:21.6  
2011-03-15 | 08:45:33.53  
2011-03-15 | 08:46:35.53  
2011-03-15 | 08:48:24.13  
2011-03-15 | 08:56:41.87  
(11 rows)
```

&nbsp;

**Results in KNIME:**

```
EQDATE EQTIME

2011-03- **14**** 07**:01:43.760  
2011-03- **14**** 07**:08:37.80  
2011-03- **14**** 07**:11:47.700  
2011-03- **14**** 07**:13:50.100  
2011-03- **14**** 07**:16:59.520  
2011-03- **14**** 07**:28:25.710  
2011-03- **14**** 07**:36:21.600  
2011-03- **14**** 07**:45:33.530  
2011-03- **14**** 07**:46:35.530  
2011-03- **14**** 07**:48:24.130  
2011-03- **14**** 07**:56:41.870
```

&nbsp;

**Expected behavior:** KNIME should not alter data on its own initiative.

&nbsp;

---

<div class="post-metadata">

**Author:** ![thor](https://forum-cdn.knime.com/user_avatar/forum.knime.com/thor/32/4_2.png) [@thor](https://forum.knime.com/u/thor)\
**Post date:** [May 21, 2013, 1:57pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/2 "2013-05-21T13:57:00Z")

</div>

The difference in the day looks really strange. Can you double-check that it is in fact one day off? The different in the hour is caused by timezones. KNIME expects dates in the database in UTC time but displays it in your local time zone. This can be confusing and we are currently working on better time zone in KNIME in general.

---

<div class="post-metadata">

**Author:** ![rd0002](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/r/2bfe46/32.png) [@rd0002](https://forum.knime.com/u/rd0002)\
**Post date:** [May 21, 2013, 2:54pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/3 "2013-05-21T14:54:41Z")

</div>

\> Can you double-check that it is in fact one day off?

Yes, it IS one day off. I imported all data in the DB and it corresponds to what was in the original text files (mostly CSVs)

&nbsp;

&nbsp;\> The different in the hour is caused by timezones.

\> KNIME expects dates in the database in UTC time but displays it in your local time zone.

\> This can be confusing and we are currently working on better time zone in KNIME in general.

That is indeed confusing ![smiley](https://forum-cdn.knime.com/sites/all/libraries/ckeditor/plugins/smiley/images/regular_smile.gif "smiley")

IMO KNIME should pass input data 1:1 unless told to change (or assume) something.

&nbsp;

My system TZ is UTC+1 plus summertime, what means UTC+2 is in effect.

&nbsp;

Two more examples:

Content of a "timestamp without timezone" field: "2012-07-27 **12** :47:18.416116"

In KNIME it becomes: 2012-07-27T **10** :47:18.416

&nbsp;

**select now() from dual** (output has type _timestamp with timezone_)

Postgresql gives&nbsp;"2013-05-21 **14** :42:02.418295+02"

KNIME says "2013-05-21T **12** :42:35.140"

(Local time was 14:43:_something_ when writing this)

---

<div class="post-metadata">

**Author:** ![andyg](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/5f8ce5/32.png) [@andyg](https://forum.knime.com/u/andyg)\
**Post date:** [May 21, 2013, 11:49pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/4 "2013-05-21T23:49:27Z")

</div>

Yeah this problem has been around for a while and either my team mate or I (I cant remember who is was) has reported this in the past. We actually use a Simple Java Snippet node in order to correct dates.

DateFormat format =  
 new SimpleDateFormat("yyyy-MM-dd");

Date dt = new Date();  
 try{  
 &nbsp;dt = format.parse($Put the date colum here$);  
 dt.setTime(dt.getTime()+1 \* 24&nbsp; \* 60 \* 60 \* 1000); }  
 catch(Exception e){}  
 return format.format(dt);

&nbsp;

---

<div class="post-metadata">

**Author:** ![Lisandra\_Bravo](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/l/db5fbb/32.png) [@Lisandra\_Bravo](https://forum.knime.com/u/Lisandra_Bravo)\
**Post date:** [May 22, 2013, 9:07pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/5 "2013-05-22T21:07:48Z")

</div>

Hi, i have this problem, but i need a way to fix the time part too. Some body can helpme???

Reggards

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:18pm UTC](https://forum.knime.com/t/bug-wrong-display-of-date-and-time-fields-read-from-postgresql/2691/6 "2023-06-23T20:18:11Z")

</div>


