Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-24 Thread Dmitry Koterov
BTW there are a much more short version of this: CREATE OR REPLACE FUNCTION int_equal(interval, interval) RETURNS boolean IMMUTABLE STRICT LANGUAGE sql AS 'SELECT $1::text = $2::text'; On Wed, Aug 8, 2012 at 4:51 PM, Albe Laurenz laurenz.a...@wien.gv.atwrote: Then maybe you should use

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Albe Laurenz
Dmitry Koterov wrote: I've just discovered a very strange thing: SELECT '1 mon'::interval = '30 days'::interval -- TRUE??? This returns TRUE (also affected when I create an unique index using an interval column). Why? I know that Postgres stores monthes, days and seconds in interval

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Dmitry Koterov
Of course NOT. '1 mon' and '30 days' have different meaning. So they should not be equal. I understand that conversion to seconds is a more or less correct way to compare intervals with and . But equality is not the same as ordering (e.g. equality is typically used in JOINs and unique indices).

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Craig Ringer
On 08/08/2012 05:54 PM, Albe Laurenz wrote: Of course this is not always correct. But what should the result of INTERVAL '1 month' = INTERVAL '30 days' be? FALSE would be just as wrong. NULL? In all honesty, it's a reasonable fit for NULL in its uncertain/unknowable personality, because

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Anthony
Should now plus 157785000 seconds in text be NULL, because we don't know how many leap seconds will be added? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Albe Laurenz
Dmitry Koterov wrote: I've just discovered a very strange thing: SELECT '1 mon'::interval = '30 days'::interval -- TRUE??? Intervals are internally stored in three fields: months, days and microseconds. A year has 12 months. PostgreSQL converts intervals into microseconds before

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Albe Laurenz
Craig Ringer wrote: Of course this is not always correct. But what should the result of INTERVAL '1 month' = INTERVAL '30 days' be? FALSE would be just as wrong. NULL? In all honesty, it's a reasonable fit for NULL in its uncertain/unknowable personality, because two intervals that

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Craig Ringer
On 08/08/2012 08:56 PM, Albe Laurenz wrote: Hmmm. How would you define an ordering in that case? And without an ordering, you couldn't use btree indexes on interval columns, right? Or, as Anthony noted, what about leap seconds? I'm not advocating changing the behaviour of interval types.

Fwd: Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-08 Thread Michael Trausch
This was supposed to go to the list. Sorry. -- Forwarded message -- From: Michael Trausch m...@trausch.us Date: Aug 8, 2012 10:12 AM Subject: Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY? To: Albe Laurenz laurenz.a...@wien.gv.at There is root in accounting

[GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-07 Thread Dmitry Koterov
Hello. I've just discovered a very strange thing: SELECT '1 mon'::interval = '30 days'::interval -- TRUE??? This returns TRUE (also affected when I create an unique index using an interval column). Why? I know that Postgres stores monthes, days and seconds in interval values separately. So

Re: [GENERAL] Interval 1 month is equals to interval 30 days - WHY?

2012-08-07 Thread Dmitry Koterov
...and even worse: SELECT ('1 year'::interval) = ('360 days'::interval); -- TRUE :-) SELECT ('1 year'::interval) = ('365 days'::interval); -- FALSE :-) On Tue, Aug 7, 2012 at 4:42 PM, Dmitry Koterov dmi...@koterov.ru wrote: Hello. I've just discovered a very strange thing: SELECT '1