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
 Script Library
 Difference between dates

Author  Topic 

kishoremcp
Starting Member

41 Posts

Posted - 2014-01-27 : 04:32:43
Hi, I have two dates and i want the difference between those dates in Days:Hours:Minutes format.

please help.

2013-11-25 07:57:17.000
2014-01-17 11:39:58.000

Thanks in advance

Regards
Kishore

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-01-27 : 05:16:23
[code]select days = mins / 60 / 24,
hours = (mins / 60) % 24,
mins = mins % 60,
all_together = convert(varchar(10), mins / 60 / 24)
+ ':'
+ convert(varchar(10), (mins / 60) % 24)
+ ':'
+ convert(varchar(10), mins % 60)
from
(
select mins = datediff(minute, '2013-11-25 07:57:17.000', '2014-01-17 11:39:58.000')
) d[/code]


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

Go to Top of Page

kishoremcp
Starting Member

41 Posts

Posted - 2014-01-27 : 06:42:03
Thanks.

Regards
Kishore
Go to Top of Page
   

- Advertisement -