Interval "1 month" is equals to interval "30 days" - WHY?

From: Dmitry Koterov <dmitry(at)koterov(dot)ru>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Interval "1 month" is equals to interval "30 days" - WHY?
Date: 2012-08-07 12:42:43
Message-ID: CA+CZih5=yg9o4BM0+5mifTqnqo+1HEu+--TgUDGYqkTyhu1rig@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 how to make "=" to compare intervals "part-by-part" and not
treat "1 mon" as "30 days"?

P.S.
Reproduced at least in 8.4 and 9.1.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Marek Kielar 2012-08-07 12:49:50 Re: Clogging problem
Previous Message Adriaan Joubert 2012-08-07 12:04:43 Memory error in user-defined aggregation function