Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

subracting for age

Status
Not open for further replies.

sonny1974

Technical User
Feb 25, 2007
161
US
sql server and crystal xi

have a DOB field ex. 5/18/1947. i need to subract the DOB from today (would change daily by it self,not a hard coded today date).

just the age would be fine.

but if i can get example 60 and 9 months that would be better
 
Try using DATEPART

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
derrr..leave it to the n00b right [blush]

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
sorry im kinda slow today,not sure what the formula should be

sorry
 
Did you read over the function Alex posted?

[sub]____________ signature below ______________
The worst mistake you'll ever make is to do something simply the way you know how while ignoring the way it should be done[/sub]
 
oh didnt notice the link , ill check it out
 
This will be to the month:
Code:
select datediff(mm, DOB, getdate()) / 12 years, datediff(mm, DOB, getdate()) % 12 months

note if days difference is listed at 367 days, that's 1 year and just a hair over. It will show as 1 year 1 month.

[monkey][snake] <.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top