Re: Huh? Data typing bug?

Lists: pgsql-sql
From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Huh? Data typing bug?
Date: 2001-06-05 00:33:15
Message-ID: web-67063@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Folks,

I just subtracted two dates and got an INT4, rather than the INTERVAL I
was expecting. What goes on here?

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco


From: Grant <grant(at)conprojan(dot)com(dot)au>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Huh? Data typing bug?
Date: 2001-06-05 00:44:44
Message-ID: Pine.LNX.4.21.0106051043470.15713-100000@webster.conprojan.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

You got difference in seconds as the result?

Show some examples.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Josh Berkus" <josh(at)agliodbs(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Huh? Data typing bug?
Date: 2001-06-05 01:25:11
Message-ID: 9352.991704311@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

"Josh Berkus" <josh(at)agliodbs(dot)com> writes:
> I just subtracted two dates and got an INT4, rather than the INTERVAL I
> was expecting. What goes on here?

IIRC, number of days (as an int) is what that's supposed to produce.

If that's not what you wanted, maybe you ought to cast the dates to
timestamp or some such.

regards, tom lane


From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Huh? Data typing bug?
Date: 2001-06-05 01:56:36
Message-ID: web-67096@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-sql

Tom,

> IIRC, number of days (as an int) is what that's supposed to produce.
>
> If that's not what you wanted, maybe you ought to cast the dates to
> timestamp or some such.

I see. It was never made clear to me that here the DATE type differs
from DATETIME and TIMESTAMP significantly.

This makes some sort of sense, now.

Correct me if I'm wrong:

DATE + INT4 = DATE
DATE - DATE = INT4

But:

DATETIME + INTERVAL = DATETIME
DATETIME - DATETIME = INTERVAL

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco