Find employees aged 16 and younger in ORACLE SQL

Hi

im trying to write a query which finds any staff which are 16 or younger using  a CTE.

BIRTH_DATE <= sysdate - 16*12

This isnt working though.

Is my syntax wrong?

Thanks
Richiep86Asked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
You need to check for greater or equal, not less or equal. And dates are represented in fractions of a day, not months:
   BIRTH_DATE >= sysdate - 16*365

However, it is much better to use the date specific functions or intervals:
   BIRTH_DATE >= sysdate - interval '16' years
or
   BIRTH_DATE >= add_months(sysdate, -16*12)
0
 
Richiep86Author Commented:
Perfect!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.