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
 Transact-SQL (2000)
 Datediff SQL vs DateDiff Access?

Author  Topic 

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-03 : 06:57:19
Morning,

I am having the hardest time converting these queries from access to SQL. in Access the function:
AgeYrs: DateDiff("d",[INSERVICE],Now())/365
Gives me this result:

14.5972602739726

in SQL the function:
AgeYrs = DATEDIFF(d,INSERVICE,getdate())/365
gives me only 14 no decimal places. How can I make the SQL funtion mimic the access one?

Thanks so much

Laura

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-03 : 07:11:09
by default it convert it as Integer
You have to convert the result to float
use 365.0 instead of 365

Madhivanan

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

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-03 : 07:35:08
Ahhh thanks for that. It only goes out 6 places. Is it possible to make it go more?

Thanks

Laura
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-08-03 : 08:01:36
Yes,

USE 365.000000000000



Duane.
Go to Top of Page

lauramayer
Posting Yak Master

152 Posts

Posted - 2005-08-03 : 08:06:05
Yea! That was it thanks.

Laura
Go to Top of Page
   

- Advertisement -