Re: [SQL] Problem with datetime

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: holm(at)freibergnet(dot)de
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [SQL] Problem with datetime
Date: 1999-10-29 13:44:55
Message-ID: 1895.941204695@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Holm Tiffe <holm(at)freibergnet(dot)de> writes:
> But now both days at on time:

> SELECT sum(stop-start) FROM logs WHERE name = 'intern-mw' and
start> = '27-10-1999' AND stop < ('28-10-1999'::datetime + '1 day'::timespan);
> sum
> -------------------------
> @ 12 hours 51 mins 4 secs
> (1 row)

> uups what's happening here ?

> I've doublechecked the WHERE clause, It is ok, the right tuples are selected,
> but 3h + 4.5h are not 13h! Wat I'm doing wrong here ?

Maybe I'm missing something obvious, but it seems to me that the above
command will include log entries that cross the midnight boundary
between the two dates, whereas neither of the other two do. Seems like
you must have about 5.5h worth of such entries...

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Oleg Bartunov 1999-10-29 14:27:40 Re: [SQL] trivial problem
Previous Message Imtiaz. S. M 1999-10-29 13:36:28 Re :Setting default row value after select into table