Results 1 to 8 of 8

Thread: Celebrate Birthday Of Employees Query

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Answers
    3

    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.


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Celebrate Birthday Of Employees Query

    select * from emp where to_char(dob,'ddmm')=to_char(sysdate,'ddmm')


  3. #3
    Junior Member
    Join Date
    Feb 2008
    Answers
    28

    Re: Celebrate Birthday Of Employees Query

    select * from emp where to_char(dob,'ddmmRRRR')=to_char(sysdate,'ddmmRRRR')

    Jaya


  4. #4
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    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')


  5. #5
    Junior Member
    Join Date
    Feb 2008
    Answers
    3

    Re: Celebrate Birthday Of Employees Query

    Quote Originally Posted by krishnaindia2007 View Post
    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')
    Thanks for your valuable time.
    Pragati


  6. #6
    Junior Member
    Join Date
    Feb 2008
    Answers
    28

    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.


    Jaya

    Last edited by jaya_geek; 02-29-2008 at 01:39 PM.

  7. #7
    Junior Member
    Join Date
    Feb 2008
    Answers
    15

    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


  8. #8
    Junior Member
    Join Date
    Mar 2008
    Answers
    6

    Re: Celebrate Birthday Of Employees Query

    I think this could be the short and simple answer :
    select * from emp where trunc(dob)=trunc(sysdate)

    Last edited by satya_vinayan; 03-04-2008 at 06:51 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact