Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Wich Birthdays for two given dates
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00363237
Message ID:
00363271
Vues:
16
Hi John & George,

It could be easily done.

First assumption: year(dend)-year(dstart)<=1 (within the same year, or, say,

8/11/99 to 5/5/00

Otherwise, all clients with not empty(DOB) quilified.

Let's assume for simplicity (otherwise there could be leap year issue,
which could be resolved more clever...), that year(dend)=year(dstart)
local lnYear
lnYear=year(dstart)
SELECT * FROM clients ;
   WHERE between(ctod(str(month(clients.dob),2)+'/'+str(day(clients.dob),2)+'/'+str(lnYear,4)) ,dstart, dend)
* Note - better use strict date format and restore date respectively, but I just don't remember this format...




>>
>>*dob = birthdate, dstart = initial date, dend = final date
>>
>>SELECT * FROM clients ;
>>   WHERE MONTH(clients.dob) >= MONTH(dstart) AND ;
>>         MONTH(clients.dob) >         DAY(clients.dob) >= DAY(dstart) AND ;
>>         DAY(clients.dob) >
>
>Gonz,
>
>Won't work if the day number returned by DAY() for the dstart variable is larger than the value returned by DAY(dend).
>
>I haven't given this much thought, but the first thing that comes to mind is, unfortunately, a UDF.
>SELECT * FROM clients;
>  WHERE DateRange(clients.dob, dstart, dend)
>
>FUNCTION DateRange
>  * VFP 6.0 required
>  LPARAMETERS tDOB, tdStart, tdStop
>
>  LOCAL llresult, lnmonth, lnday, ldthisdate
>  lnmonth = MONTH(tDOB)
>  lnday = DAY(tDOB
>  ldthisdate = DATE(YEAR(DATE()), lnmonth, lnday)
>  llresult = BETWEEN(ldthisdate, tdStart, tdStop)
>  RETURN llresult
>ENDFUNC
I'm not sure if this can even be done without the UDF. 'Course, haven't really given it a lot of thought.< g >
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform