Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to find first non-vacation day before given date
Message
De
03/02/2006 17:09:41
 
 
À
03/02/2006 16:40:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01093556
Message ID:
01093566
Vues:
22
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 ?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform