Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Operator on numtoyminterval(months_between(trunc(sysdate),DATE_OF_BIRTH),'month') as age field

Rajneesh S-OracleApr 12 2020 — edited Apr 12 2020

Hello All,

I want to list all members who are turning to 65 (age in years).

for this I used numtoyminterval(months_between(trunc(sysdate),DATE_OF_BIRTH),'month') function and arguments.

Example of values returned are : +13-00, +64-9, +65-04 etc.

Now I want to list all members whose DOB is greater than 64 years and 6 months , but not greater than +65-00.

Now I observed that =, >,< , like kind of operators are not allowed with interval Year to month data type.

One workaround is-

MONTHS_BETWEEN(TRUNC(SYSDATE),DATE_OF_BIRTH) BETWEEN 774 AND 780

However any idea if I can manage operator on year to moth interval? or any other suggestions?

Thanks,

Rajneesh

This post has been answered by Solomon Yakobson on Apr 12 2020
Jump to Answer
Comments
Post Details
Added on Apr 12 2020
8 comments
765 views