I have an SQL table like Where DateDiff in format (hh.mm)
DateDiff ATM 1.45 121 1.50 121 1.50 121
When I make Sum from DateDiff on Group by in ATM, it will show the result, for example
4.45 121
But the actual time difference of the day should be
5.25 121
How can we do the same in SQL Query
Select Sum(Cast(Convert(Varchar(10),DATEDIFF(HOUR,TicketRaisedOn,ClosedOn))+'.'+ Convert(Varchar(10),DATEDIFF(MINUTE,TicketRaisedOn,ClosedOn)%60) as Numeric(18,2)))[Down Time],ATM From Ticket Where Closed=1 And DATEPART(DAYOFYEAR,GETDATE())=DATEPART(DAYOFYEAR,TicketRaisedOn) Group BY ATM Order By [Down Time] Desc
TicketRaisedOn and ClosedOn refer to DateTime
Database is SQL Server 2008
Above, the query will print the result this way (But its wrong, because it will sum it up as a number, not as a date format)
Down Time ATM 16.95 282 14.46 1811 14.20 52 14.04 936
Data examples
Select TicketRaisedOn,ClosedOn,ATM From Ticket Where ATM=282 And DATEPART(DAYOFYEAR,GETDATE())=DATEPART(DAYOFYEAR,TicketRaisedOn) And Closed=1 TicketRaisedOn ClosedOn ATM 2012-12-21 01:15:23.793 2012-12-21 15:11:59.240 282 2012-12-21 16:42:29.820 2012-12-21 18:21:30.797 282