Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 age calculation

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-03-02 : 06:58:26
Hi all,

can you help me in age calculation.. when provided dob.
sp should load data for one month, in parameter will always be
DD=01 MM=Any YYYY=Any eg( 01/12/1989 or 01/11/2001 etc...)
means complete date with 1st of any month

[purple]
[b]
Proc Age_cal @start_of_month_date datetime
as
Begin

Declare @tmp_date
set @tmp_date=@start_of_month_date -- in parameter date

While @tmp_date < dateadd(mm,1,@start_of_month_date)
begin
Insert into #temp_tab
select xyz.id,@tmp_date,AGE /*needs to calculate*/,abc.dob,
is_birthday/* needs to check if it is b'day then 1 else 0*/
from abc join xyz on abc.id=xyz.id
end

end
[\b]
[\purple]

I did used datediff(yyyy,dob,@tmp_date) but not working..
I want age in whole number say if the person is 11 months old
then age = 0

if he is 1year 11 months then it should give me 1year age

the temp_date should cross his b'day or should be equal to b'day to increament the age.

kindly help..

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-03-02 : 07:18:59
see some solutions are given in this
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=120499
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-03-02 : 08:40:42
Also refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=74462

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -