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.
| Author |
Topic |
|
Kotti
Posting Yak Master
129 Posts |
Posted - 2009-08-21 : 01:18:05
|
| Hi Friends,I had table which has a field called dateofbirth of varchar type.Now i need to calculate the age and select between two ages My table has id dateofbirth1 04/30/19802 6/3/19863 6/3/19854 6/3/19845 6/3/1983here when i use the below query i can get the age,but i need the ages between 18 to 23 .How can i get that?SELECT DATEDIFF(year, dateofbirth ,getdate()) as NoOfYear from Table1Thanks |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-08-21 : 01:21:13
|
| Try this once,select * from table where DATEDIFF(year, dateofbirth ,getdate()) between 18 and 23 |
 |
|
|
Kotti
Posting Yak Master
129 Posts |
Posted - 2009-08-21 : 01:28:04
|
quote: Originally posted by Nageswar9 Try this once,select * from table where DATEDIFF(year, dateofbirth ,getdate()) between 18 and 23
Thanks Nageshwar,I didn't think this simple thing.Once again thanks for you. |
 |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-08-21 : 01:29:07
|
quote: Originally posted by Kotti
quote: Originally posted by Nageswar9 Try this once,select * from table where DATEDIFF(year, dateofbirth ,getdate()) between 18 and 23
Thanks Nageshwar,I didn't think this simple thing.Once again thanks for you.
Ok, Welcome |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|
|