Re: [SQL] Interval subtracting

From: Mark Dilger <pgsql(at)markdilger(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: [SQL] Interval subtracting
Date: 2006-03-01 17:05:09
Message-ID: 4405D445.4000200@markdilger.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches pgsql-sql

Tom Lane wrote:
> "Milen A. Radev" <milen(at)radev(dot)net> writes:
>
>>Milorad Poluga напиÑа:
>>
>>>>SELECT '10 years 1 mons 1 days'::interval - '9 years 10 mons 15 days'::interval
>>>>?column?
>>>>---------------
>>>>3 mons -14 days
>>>>
>>>>Why not '2 mons 16 days' ?
>
>
>>Please read the last paragraph in section 8.5.1.4 of the manual
>>(http://www.postgresql.org/docs/8.1/static/datatype-datetime.html#AEN4775)
>>. It mentions the functions named "justify_days" and "justify_hours"
>>that could do what you need.
>
>
> justify_days doesn't currently do anything with this result --- it
> thinks its charter is only to reduce day components that are >= 30 days.
> However, I think a good case could be made that it should normalize
> negative days too; that is, the invariant on its result should be
> 0 <= days < 30, not merely days < 30. Similarly for justify_hours.
> Comments anyone? Patch anyone?

Sure, if nobody objects to this change I can write the patch.

mark

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2006-03-01 17:26:33 Re: pg_config, pg_service.conf, postgresql.conf ....
Previous Message Simon Riggs 2006-03-01 17:02:45 Re: Vacuum dead tuples that are "between" transactions

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2006-03-01 17:59:29 Re: [SQL] Interval subtracting
Previous Message Tom Lane 2006-03-01 16:08:05 Re: cleanup error reporting

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Fenbers 2006-03-01 17:32:26 Change date format through an environmental variable?
Previous Message Alvaro Herrera 2006-03-01 15:00:16 Re: [SQL] regarding grant option