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)
 year of experience

Author  Topic 

sent_sara
Constraint Violating Yak Guru

377 Posts

Posted - 2006-12-15 : 05:26:27
gworker table
name='senthil'
column doa(Date of appointment)='2000-04-01'
age=25

just 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 YearsOfExp
From gworker[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

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 YearsOfExp
From gworker


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"

Go to Top of Page

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 error
select convert(numeric(2,1), datediff(month, cast('2004-04-01' as Datetime), getdate())/12.0) as YearsOfExp
select Round(datediff(month, cast('2004-04-01' as Datetime), getdate())/12.0,1) as YearsOfExp


Madhivanan

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

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 YearsOfExp
From gworker




Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -