Re: [SQL] Problem with datetime - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] Problem with datetime
Date
Msg-id 1895.941204695@sss.pgh.pa.us
Whole thread Raw
In response to Problem with datetime  (Holm Tiffe <holm@freibergnet.de>)
List pgsql-sql
Holm Tiffe <holm@freibergnet.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


pgsql-sql by date:

Previous
From: "Imtiaz. S. M"
Date:
Subject: Re :Setting default row value after select into table
Next
From: Oleg Bartunov
Date:
Subject: Re: [SQL] trivial problem