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!

How to find people with up and coming birthday using an SQL query only

426702Nov 29 2006 — edited Nov 29 2006
Dear Oracle users.

I am wondering did anyone come acorsss an SQL query (yes please SQL query only!) which can bring back rows (let say employee) who have birthday in the next 30 days. (I did some internet searching no luck at the moment)

We have a try ourselves... we learn some of the task we need to overcome, I hope the following list may help:-

1. leap year people born on 29-Feb need to be considered to born on 28-Feb (sorry you cannot tell people you are 10 years old while you really is 40)

2. if sysdate is around december, the sql must able to return people in January.

3. Some strange thing happen to one of our record when a day of birth is 1927..(it may be our data)...


Table:

create table ivan_emp
(emp_no number,
emp_birthday date);

SQL insert for example data:-

insert into ivan_emp
values(01,'21-DEC-1971');
insert into ivan_emp
values(02,'15-JAN-2005');
insert into ivan_emp
values(03,'10-MAR-1927');



select * from ivan_emp


emp_no emp_birthday
== =============
01 21-DEC-1971
02 15-JAN-2005
03 10-MAR-1927


Any suggestion, solution are very very welcome!

regards

Ivan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 27 2006
Added on Nov 29 2006
23 comments
6,927 views