Re: I need a SQL...

Поиск
Список
Период
Сортировка
От Andrew L. Gould
Тема Re: I need a SQL...
Дата
Msg-id 200309110707.07917.algould@datawok.com
обсуждение исходный текст
Ответ на I need a SQL...  (Bjørn T Johansen <btj@havleik.no>)
Ответы Re: I need a SQL...  (Bjørn T Johansen <btj@havleik.no>)
Список pgsql-general
On Thursday 11 September 2003 06:25 am, Bjørn T Johansen wrote:
> I need to write a SQL that calculates the interval between a start time
> and a stop time. This is the easy part. The problem is that I only have
> the time part, i.e. no date, so how can I be sure to also calculate the
> interval if the start time is before midnight and the stop time is after
> midnight?
>
>
> Regards,
>
> BTJ

If the activity or period you are measuring can equal or exceed 12 hours, you
won't be able to calculate it reliably without a start date and a stop date.
If the periods are always less than 12 hours (and you assume all the data is
good), then stop times that are less than start times would indicate an
intervening midnight.

The dates do not have to be in the same fields as the times, since you can add
date and time data to create a timestamp for datetime calculations:

(stop_date + stop_time) - (start_date + start_time)

Best of luck,

Andrew Gould

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: query-question
Следующее
От: Bjørn T Johansen
Дата:
Сообщение: Re: I need a SQL...