How to find first non-vacation day - Mailing list pgsql-general

From Andrus Moor
Subject How to find first non-vacation day
Date
Msg-id ds0ieq$17j3$1@news.hub.org
Whole thread Raw
Responses Re: How to find first non-vacation day
List 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 by date:

Previous
From: Rikard Pavelic
Date:
Subject: Re: grouping of functions
Next
From: Philip Hallstrom
Date:
Subject: Re: How to find first non-vacation day