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 |
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2006-12-15 : 05:26:27
|
| gworker tablename='senthil'column doa(Date of appointment)='2000-04-01'age=25just i need to find year of experience at present???????/ |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-15 : 05:59:42
|
| [code]select convert(numeric(2,1), datediff(month, doa, getdate())/12.0) as YearsOfExpFrom gworker[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
sent_sara
Constraint Violating Yak Guru
377 Posts |
Posted - 2006-12-15 : 06:24:06
|
Hello mr harsh,while generating the below code error occured is:Arithmetic overflow error converting numeric to data type numeric.quote: Originally posted by harsh_athalye
select convert(numeric(2,1), datediff(month, doa, getdate())/12.0) as YearsOfExpFrom gworker Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
|
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-12-15 : 06:49:41
|
| What is the datatype of doa?Run this and see if you get errorselect convert(numeric(2,1), datediff(month, cast('2004-04-01' as Datetime), getdate())/12.0) as YearsOfExpselect Round(datediff(month, cast('2004-04-01' as Datetime), getdate())/12.0,1) as YearsOfExpMadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2006-12-15 : 07:02:54
|
This should work fine:select convert(numeric(4,1), datediff(month, doa, getdate())/12.0) as YearsOfExpFrom gworker Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
|
|
|
|
|