Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Baby question about counting AGE!

0 views
Skip to first unread message

Ray

unread,
Mar 9, 2000, 3:00:00 AM3/9/00
to
Sorry people,

I am new to SQL, so, can anyone show me the command used/the way to count
the AGE of a person given only their BIRTHDATE (eg: 19-JUL-58) ? I know we
can use the present date to minus the birthdate, but how?

Thanks

RAY

Brian W. Chester

unread,
Mar 9, 2000, 3:00:00 AM3/9/00
to
Ray,

If BIRTHDATE is stored as an Oracle date field then simply

SELECT sysdate - birthdate FROM some_table
WHERE person_field = 'some_person';

If BIRTHDATE is stored as char, or varchar:

SELECT sysdate - TO_DATE(birthdate, 'DD-MON-YY')
FROM some_table
WHERE somecondition;

Of course this introduces some Y2K issues with the YY but you get the drift!

HTH

Brian

"Ray" <raymo...@home.com> wrote in message
news:PvPx4.48635$pN1.4...@news1.rdc1.nj.home.com...

0 new messages