Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to find first non-vacation day before given date
Message
From
03/02/2006 17:09:41
 
 
To
03/02/2006 16:40:11
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
Miscellaneous
Thread ID:
01093556
Message ID:
01093566
Views:
21
How about something like
dVac = {some date)
SELECT * FROM vacation ;
 WHERE dend = (SELECT MAX(dend) FROM vacation WHERE dend >= dVac);
 INTO CURSOR curTemp

? IIF(curTemp.dstart <= dVac, curTemp.dstart-1,dVac)
This returns the original date if it is not in the vacation period. You may have to tweak it for a different value if that is not what you need. You also need a final record where dEnd is very large to cover the case when the input date is past the last vacation date in the table.

HTH.........Rich



>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 ?
Previous
Reply
Map
View

Click here to load this message in the networking platform