HOW TO FIND OUT DATE OF BIRTH FROM THE TABLE

  • Hi all

     

    I have a table "emp_detail" in this table 'emp_dob' coloum that carrying Date of birth of employee xyz ex:"1976-12-19 00:28:45.263"

    here my problem is i have to send mail to HRD department on 18th of December saying that tommarow is the 'xyz' Birthday

     I have procedure for sending mails,please some body help me on next approach

     

    Thanks in Advance

    Saivyshnav 

  • This seems to do it (didn't test it).

     

    http://www.sqlservercentral.com/scripts/viewscript.asp?scriptid=1332

  • a) Gather the appropriate names and ages(temporary table)

       declare @tomorrow datetime
       select @tomorrow = dateadd(d, 1, getdate())
       select emp_name, YearsOld=datediff(yyyy, emp_dob, @tomorrow+1)  -- +1, to avoid dealing with time stripping 
       into #EmpBirthdays
       from emp_detail
       where datepart(m,emp_dob)=datepart(m,@tomorrow)
         and datepart(d,emp_dob)=datepart(d,@tomorrow)

    b) Use a cursor to traverse the results and build your @mail_body string

    (Perhaps add some quick enclosing HTML tags to make it look nice)

    c) Send the string to your mail proc with the appropriate From, To (First test it on your own e-mail address) and Subject 'Employee Birthdays for ' + convert(char(10), @tomorrow, 101) parameters

    d) Schedule the task to run automatically

    (It's strange that they're only asking for one day's worth of birthdays. Usually, they need a whole month's worth, up front. Must be working in a large company.)

  • .. or they just didn't think it through.  But I agree that this is a somewhat strange requirement.

  • May be a governmental agency if they have the TIME of birth on file.

    That would explain the quantity...

  • That could make sens.... but then again, I ain't receiving any birthday letter from any gouvernemental agency so I guess it may be for some other reason .

  • It can be a Marketing Scheme from a company with lots of clients. I was approched by Ford once for such a task. But In their case, the wanted to greet the celebrants via SMS.


    Ronald San Juan | SQL DBA
    ID 710124 ~ Code "Northwind"

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply