>>
>>
>>select * from People where DOB between
>>date(year(DOB), month(ldStart), day(ldStart)) and date(iif(year(ldEnd)>year(ldStart), year(DOB+1),year(DOB)), month(ldEnd), day(ldEnd))
>>
>>from the top of my head (not tested).
>
>This is similar to David's suggestion. On the other hand, I don't see how this code would be optimized, if Visual FoxPro has to extract the year() for every record to do the comparison. In other words, the expression on the left is a field, but the expression on the right is not constant.
Run it with SYS(3054,1) and index on the DOB and tell me the result.
If it's not broken, fix it until it is.
My Blog