I think this came up again recently and somebody pointed out that the correct definition isn't as obvious as all that. The components of an interval can have different signs, so should abs('-1 day 1 hour') be '1 day -1 hour' or '1 day 1 hour'? Or what about corner cases like '1 day -25 hours'?
I agree with Sam. The absolute value of a negative interval should be equidistant from zero, not the removal of negative signs. So abs('-1 day 1 hour') should be ('1 day -1 hour'). I don't think your corner case is any different. So his function and operator should be perfectly valid.
But there is some ambiguity around the length of a month. So INTERVAL '1 month - 30 days' = INTERVAL '0 days' = INTERVAL '-1 month +30 days'. But when added to a date, it makes no change for months with 30 days, adds 1 day for months with 31 days and subtracts 2 days for February.
Scott Bailey -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general