Re: Help with date math

Поиск
Список
Период
Сортировка
От Ragnar
Тема Re: Help with date math
Дата
Msg-id 1185061359.5778.230.camel@localhost.localdomain
обсуждение исходный текст
Ответ на Help with date math  ("Chris Hoover" <revoohc@gmail.com>)
Список pgsql-general
On fös, 2007-07-20 at 11:08 -0400, Chris Hoover wrote:
> I need some help.  I am trying to replicate a function from Sybase
> ASA, and am having difficulty.
>
> I need to be able to subtract 2 date (or timestamps) and return the
> results expressed in days, weeks, month, quarters, or years.  How do I
> do this?
>
> I believe Postgres is returning the number of days when you subtract
> to days.

>
> However, I can not figure out how to get the results expressed as 7
> months,
  would not 6 months be more logical?

>  or 2 quarters, x weeks, or 0 years.

have you tried to use extract() ?

there is an old compatibility project on pgfoundry that has a
datediff function, but i have no idea how well it copies the
mssql behaviour.

http://cvs.pgfoundry.org/cgi-bin/cvsweb.cgi/mssqlsupport/datetimefunctions.sql?rev=1.1.1.1&content-type=text/x-cvsweb-markup

it looks a bit simplistic to me, but maybe that is exactly what
you need.

gnari




В списке pgsql-general по дате отправления:

Предыдущее
От: Oleg Bartunov
Дата:
Сообщение: Re: help with tsearch2 stem compile
Следующее
От: Steve Wampler
Дата:
Сообщение: CentOS 4 RPMs for 8.2.4?