14,667,121 members
Rate this:
See more:
Hi friends,
How do we find date diffrence between two dates?
I want difference like this : d(days):HH(hours):MM(Mins)
I have two date columns and want to get difference between them in the given format.
I use sql server 2008
Any help will be appreciated.
Regards,
Lok..
Posted

Rate this:

## Solution 2

```DECLARE @StartDate datetime
DECLARE @EndDate datetime

SELECT @StartDate=Date1 FROM MyDate
SELECT @EndDate=Date2 FROM MyDate

SELECT CONVERT(VARCHAR(2),ABS(DATEDIFF(dd,@StartDate,@EndDate)))
+' ' +
CONVERT(VARCHAR(2),ABS(DATEDIFF(hh,@StartDate,@EndDate)))
+' ' +
CONVERT(VARCHAR(2),ABS(DATEDIFF(MM,@StartDate,@EndDate)))```

Thanks,
Mamun
v2
Rate this:

## Solution 3

You can use following to find difference between BDate and JDate
`CONVERT(nvarchar, DATEDIFF(d, BDate, JDate)) + ':' + CONVERT(nvarchar, DATEDIFF(hh, BDate, JDate) % 24) + ':' + CONVERT(nvarchar, DATEDIFF(n, BDate, JDate) % 60)`

```SELECT
ID,
Name,
BDate,
JDate,
CONVERT(nvarchar, DATEDIFF(d, BDate, JDate)) + ':' + CONVERT(nvarchar, DATEDIFF(hh, BDate, JDate) % 24) + ':' + CONVERT(nvarchar, DATEDIFF(n, BDate, JDate) % 60) AS Difference
FROM
Temp```
v2
Rate this:

## Solution 1

http://www.sqlservercurry.com/2008/04/find-hours-minutes-and-seconds-in.html[^]
Lokesh Zende 7-Feb-11 8:51am

Ty Omi