Celebrate Birthday Of Employees Query
I have emp table. It has two columns. Emp
Name DOB(columns)
XYZ 1-dec-1979
100 records are appearing in emp table. HR whats to celebrate Birthday of those employees whose birthday falls on todays date. Write a select query to display the desired output. (Hint) we need to truncate year of sysdate and DOB.
Re: Celebrate Birthday Of Employees Query
select * from emp where to_char(dob,'ddmm')=to_char(sysdate,'ddmm')
Re: Celebrate Birthday Of Employees Query
select * from emp where to_char(dob,'ddmmRRRR')=to_char(sysdate,'ddmmRRRR')
[B][COLOR="DarkOrange"]Jaya[/COLOR][/B]
Re: Celebrate Birthday Of Employees Query
Thanks for your query jaya.
Your query will display list of employees who born on today. Drop year portion RRRR in your query to display list of employees whose birthday falls on todays date.
select * from emp where to_char(dob,'ddmm')=to_char(sysdate,'ddmm')
Re: Celebrate Birthday Of Employees Query
[QUOTE=krishnaindia2007;26901]Thanks for your query jaya.
Your query will display list of employees who born on today. Drop year portion RRRR in your query to display list of employees whose birthday falls on todays date.
select * from emp where to_char(dob,'ddmm')=to_char(sysdate,'ddmm')[/QUOTE]
Thanks for your valuable time.
Pragati
Re: Celebrate Birthday Of Employees Query
hi
@krishna
i missread the question actually.......
any way RRRR has very usefull than YYYY in some situations........any one could tell this? i think SQL programers know this concept.
[B][COLOR="DarkOrange"]Jaya[/COLOR][/B]
Re: Celebrate Birthday Of Employees Query
Hi,
the RR date format is similar to YY element, but you can use it to specify different centuries, you can use the RR date format element instead of YY.
so that the century of the return value varies according to the specified Two-Digit year and the last 2 digits of the current year.
for an Example, I will come in point by point
suppose
UR in 1998 and the date you entered is 30-mar-95 the RR will show 1998
and th YY also shows 1998;
again ur in 1998 and the date entered is 30-mar-08 the RR will show you 2008
but YY shows you 1908;
At present we are in 2008 and the date entered is 30-mar-08 the RR will show you 2008 and YY also shows you 2008.
that means the RR format will checks like 00-49 and 50-99,
But YY will checks like 00-99.
are you clear with this, any doubts Kindly reply.
byee sudheer
Re: Celebrate Birthday Of Employees Query
I think this could be the short and simple answer :
select * from emp where trunc(dob)=trunc(sysdate)