Search Postgresql Archives

Re: interval output format available that removes ambiguity ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karsten Hilbert <Karsten.Hilbert@gmx.net> writes:
> I am now looking for a way to say:
>  select age('1999-2-2', '1999-3-2', without months);
>  select age('1999-5-2', '1999-6-2', without months);
> and get "28 days" in the first and "31 days" in the second
> result.

Just subtract the two timestamps (or dates) instead of using age().
Then you get an interval that has no month component.

> However, if you say that "1 mon" is always considered 30 days

He didn't say that.  He said that when the system *must* convert a
month-based interval to days and it has no date reference for it,
it uses 30 days.  Something like "now() + '1 month'::interval"
will do the "right thing".  This IMHO is the main application of
intervals with month components ...

			regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux