How to find first non-vacation day

From: "Andrus Moor" <eetasoft(at)online(dot)ee>
To: pgsql-general(at)postgresql(dot)org
Subject: How to find first non-vacation day
Date: 2006-02-03 21:35:44
Message-ID: ds0ieq$17j3$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Philip Hallstrom 2006-02-03 22:10:04 Re: How to find first non-vacation day
Previous Message Rikard Pavelic 2006-02-03 21:21:38 Re: grouping of functions