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
 Time difference

Author  Topic 

chsrikanth
Starting Member

6 Posts

Posted - 2011-12-29 : 01:18:54
I have the following fields in my table.
UserName DateTime Action
abc 22/1/2011 23:45 xyz
def 23/1/2011 10:00 pqr

I need to know the time difference between two records.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-29 : 01:25:19
you will only have 2 records in the table ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

chsrikanth
Starting Member

6 Posts

Posted - 2011-12-29 : 01:33:00
I have many records.I have to calculate the time difference between two consequent records.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-29 : 01:37:19
How do you define which 2 record are consecutive ?

Do you have a identity column in the table that can determine the sequence ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

chsrikanth
Starting Member

6 Posts

Posted - 2011-12-29 : 02:07:51
Yes I have identity column.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-29 : 02:11:26
quote:
Originally posted by khtan

How do you define which 2 record are consecutive ?


KH
[spoiler]Time is always against us[/spoiler]





So how will you do that ?

please post more of the sample record and the expected result


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -