You are here: SQL needs AGE function. « PHP SQL « IT news, forums, messages
SQL needs AGE function.

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация