How to find first non-vacation day

Поиск
Список
Период
Сортировка
От Andrus Moor
Тема How to find first non-vacation day
Дата
Msg-id ds0ieq$17j3$1@news.hub.org
обсуждение исходный текст
Ответы Re: How to find first non-vacation day  (Philip Hallstrom <postgresql@philip.pjkh.com>)
Список pgsql-general
I have a table of vacations

create table vacation (
id integer primary key,
dstart date,
dend date );


I need to find first non-vacation day before given date.

This can be done using the following procedural vfp code

function nonvacation( dbefore )

for i=dbefore to  date(1960,1,1) step -1
  select vacation
  locate for between( i, dstart, dend )
  if not found()
    return i
    endif
  endfor
return null

but this is very slow

How to implement this as sql select statement ?

Andrus.



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

Предыдущее
От: Rikard Pavelic
Дата:
Сообщение: Re: grouping of functions
Следующее
От: Philip Hallstrom
Дата:
Сообщение: Re: How to find first non-vacation day