| 
	
 | 
 Posted by Skybuck Flying on 01/06/08 08:38 
Hello, 
 
I want to select people from a database within a certain age range. 
 
For example: 
 
Select * From TablePerson Where (Age(Birthdate) > 20) and (Age(Birthdate) <  
98) 
 
That would make it really easy. 
 
Things I have tried so far: 
 
Trail 1, SQL DateDiff function: 
 
DateDiff('yyyy', '31-12-1910', '6-1-2008' ) 
 
This is no good, it returns age 98, the real age is 97. 
 
Trail 2, Encoding min range and max range as TdateTime in Delphi. 
 
EncodeDate( 20, 0, 0 ); // failure, invalid year specified. 
 
I either need a solution in SQL or in Delphi. 
 
The only solution I can think of in Delphi is: 
 
Calculate the minimum birthday and maximum birthday, so then the question  
becomes: 
 
How to do that accurately ? 
 
Thanks for listening and any help, 
 
Bye, 
  Skybuck. 
 
P.S.: alt.php.sql newsgroup included because maybe they know something about  
SQL and maybe somebody can pass this request onto database vendors ;) :) =D
 
[Back to original message] 
 |