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
 General SQL Server Forums
 New to SQL Server Programming
 Calculate Age from DOB using a specific date

Author  Topic 

tinamiller1
Yak Posting Veteran

78 Posts

Posted - 2015-03-02 : 17:29:02
I know how to calculate age from DOB using the current date, but how do I do it if I want to say show me the age as of Jan 1, 2015. Where the DOB is short date looks like: 1946-04-13

tina m miller

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2015-03-02 : 17:38:22
Just replace getdate() with the specific date.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2015-03-03 : 00:38:14
http://www.sqlteam.com/article/datediff-function-demystified


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

Pasi
Posting Yak Master

166 Posts

Posted - 2015-03-04 : 19:22:04
Try this: convert(char(10), CAST(CAST(date_of_birth AS VARCHAR(10)) AS DATE), 101) As DOB

or if you are trying to find between dates just say from "where DOB between 205-01-01 and 1946-04-13"

not sure if that's what you want?
Pasi.

quote:
Originally posted by tinamiller1

I know how to calculate age from DOB using the current date, but how do I do it if I want to say show me the age as of Jan 1, 2015. Where the DOB is short date looks like: 1946-04-13

tina m miller

Go to Top of Page
   

- Advertisement -