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)
 Average in hours

Author  Topic 

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-08 : 16:05:47
Hi Friends,

This question is in reference to one of my previous quest.
I am trying to find the average between two dates.
I am now getting in days.
How can i get in hours
I know, we can change the datediff parameter to hour instead of day.
But it didnt seem to make an impact on my result.
can anyone help me in this?

select avg(abs(datediff(day, [test].[test date], [test1].[test1 date])) / 24.0) as [avg in days]

-- getting result as .027994

this is the statement which i am using now.
Actually wat is the cal for dividing it by 24?
This i got from some reference.

Thanks

rlaubert
Yak Posting Veteran

96 Posts

Posted - 2007-03-08 : 16:13:39
The 24 appears to be hours in a day. Hence if you devide the time by 24 you get days. Drop the /24.0 and you should get what you are looking for.

Raymond Laubert
MCDBA, MCITP:Administration, MCT
Go to Top of Page

reflex2dotnet
Yak Posting Veteran

99 Posts

Posted - 2007-03-08 : 16:25:21
Thanks..
Go to Top of Page
   

- Advertisement -