Re: Re: Data type confusion

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Re: Data type confusion
Дата
Msg-id web-97584@davinci.ethosmedia.com
обсуждение исходный текст
Ответ на Re: Data type confusion  (Allan Engelhardt <allane@cybaea.com>)
Ответы Re: Re: Data type confusion
Список pgsql-sql
Allan,

> I see now what you are trying to do.  It sort of makes sense, but I'm
> still really reluctant to give (semantic or otherwise) meaning to
> "yesterday divided by tomorrow" .....

I don't agree.  Consider, for example, this statement:

'30 weeks ago'::INTERVAL / '2 weeks'::INTERVAL = -15
Just as 
-30 / 2 = -15

To phrase the equation above:  "How many two week periods is thirty
weeks ago?  Minus fifteen, or fifteen ago." 

This makes perfect sense to me.  

> It seems to me that such a function would be more generally useful
> than the division of intervals.  What you really want to do is not to
> divide intervals, but to express them in different time units.  Or am
> I missing something (again)?

From my pespective?  Yes, you are. (For one thing, the CONVERT function
in Postgres converts between unicode character sets, not data-types).

Look, if I'm designing a payroll application for a company with
bi-weekly payroll, I will want a report that shows how many payroll
periods for which an employee has been employed.  Thus I will want to:

periods_employed := (current_timestamp - date_hired) / '2
weeks'::INTERVAL

I don't want to go through a bunch of non-ANSI SQL-compliant conversion
functions to do it.  Especially not as this is just what the ANSI SQL
data type and operator specs are designed to support.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete
informationtechnology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small
businesses       fax 621-2533   and non-profit organizations.      San Francisco
 


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

Предыдущее
От: Thomas Good
Дата:
Сообщение: Re: prob with PERL/Postgres
Следующее
От: Allan Engelhardt
Дата:
Сообщение: Re: prob with PERL/Postgres