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
 DateDiffrence

Author  Topic 

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-26 : 11:52:23
Dear All,

I want diffrence in MM:SS.For example 30.10.

Please suggest

From_Date To_Date
2009-12-23 18:04:54.000 2009-12-23 18:04:57.000
2009-12-23 21:28:17.000 2009-12-23 21:28:25.000
2009-12-24 08:27:27.000 2009-12-24 08:42:28.000
2009-12-24 09:59:17.000 2009-12-24 09:59:18.000
2009-12-24 10:48:07.000 2009-12-24 13:10:24.000
2009-12-24 11:53:20.000 2009-12-24 13:38:11.000
2009-12-24 13:03:23.000 2009-12-24 13:48:33.000

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-26 : 11:55:06
[code]SELECT CONVERT(varchar(8),DATEADD(ss,DATEDIFF(ss,From_Date,To_Date),0),108) FROM table[/code]
Go to Top of Page

sanjay5219
Posting Yak Master

240 Posts

Posted - 2010-01-26 : 12:07:02
Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-26 : 12:12:45
welcome
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2010-01-26 : 13:58:40
This also does it, if From_Date and To_Date are datatype DATETIME.
select convert(varchar(8),To_Date-From_Date,108)


CODO ERGO SUM
Go to Top of Page
   

- Advertisement -