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
 General SQL Server Forums
 New to SQL Server Programming
 Finding differences between dates in a single colu

Author  Topic 

lbeese
Starting Member

24 Posts

Posted - 2008-02-28 : 16:10:10
I have a log table that displays the history of the status of an entity and the date the status changed.

member_id | modification_date | status

I wish to find the differences between datetime values in different rows of the modification_date column. I would need the amount of time between whatever the next sequential time was for the member. I would also need to know the status change in that time. I don't know how to do this with just one date column.

Any assistance is appreciated.

Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-28 : 16:13:39
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-02-29 : 05:42:24
something like

select t1.member_id,t1.modification_date,t1.status,datediff(hour,t1.modification_date,t2.modification_date) as time_diff from table t1 inner join table t2
on t1.modification_date<t2.modification_date

Madhivanan

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

- Advertisement -