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 |
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-08 : 09:28:24
|
HiI have two dates columns in 2 different tablestable1regidregdatetable2regidlogindatehow to take the difference between these two dates,and find the average, in a stored procedure? |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-02-08 : 09:32:32
|
Difference in what terms? day, month, year?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-08 : 09:32:42
|
[code]select avg(abs(datediff(hour, t1.regdate, t2.regdate)) / 24.0) as [avg in days]from table1 t1 inner join table2 t2 on t1.regid = t2.regid[/code] KH |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-08 : 09:48:51
|
[code]declare @d1 datetime, @d2 datetimeselect @d1 = '19690906', @d2 = '19760608'select DATEADD(day, DATEDIFF(day, @d1, @d2) / 2, @d1), DATEADD(day, DATEDIFF(day, @d2, @d1) / 2, @d2)[/code]Peter LarssonHelsingborg, Sweden |
 |
|
reflex2dotnet
Yak Posting Veteran
99 Posts |
Posted - 2007-02-08 : 10:29:52
|
Thanks EveryoneI will try to use these statements in my SP |
 |
|
|
|
|
|
|