So, I basically copy and paste all my reports, I don't know anything about SQL. I have jsut pasted the conversion from days to hours and mins etc. the past few times I used it, but now I need some assistance, I wanted to change the period from just days to days, hours and minutes.
Google gets complex very fast, when you google this error.
Here is my code so far, but it says "Arithmetic overflow error converting expression to data type int."
Select Top 1000000 DatePart(yyyy, htblticket.date) As Year,
DatePart(mm, htblticket.date) As Month,
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,Avg(Cast(DateDiff_big(ss,
htblticket.date, htblticket.ticketid) As decimal))) / 3600 / 24))) +
' days, ' +
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,Avg(Cast(DateDiff_big(ss,
htblticket.date, htblticket.ticketid) As decimal))) / 3600 % 24))) +
' hours, ' +
Convert(nvarchar(10),Ceiling(Floor(Convert(integer,Avg(Cast(DateDiff_big(ss,
htblticket.date, htblticket.ticketid) As decimal))) % 3600 / 60))) +
' minutes' As [Elapsed Time]
From htblticket
Inner Join (Select Top 1000000 htblticket.ticketid,
Max(htblhistory.date) As CloseDate
From htblticket
Inner Join htblticketstates On htblticketstates.ticketstateid =
htblticket.ticketstateid
Inner Join htblhistory On htblhistory.ticketid = htblticket.ticketid
Inner Join htblticketstates htblticketstates1 On
htblhistory.ticketstateid = htblticketstates1.ticketstateid
Inner Join htblhistorytypes On htblhistorytypes.typeid =
htblhistory.typeid
Where htblticketstates.statename = 'Closed' And
htblticketstates1.statename = 'Closed' And htblhistorytypes.name
In ('Status changed', 'Note added and state changed',
'Internal note added and state changed')
Group By htblticket.ticketid) As ClosedDate On ClosedDate.ticketid =
htblticket.ticketid
Where htblticket.spam <> 'True'
Group By DatePart(yyyy, htblticket.date),
DatePart(mm, htblticket.date)
Order By Year Desc,
Month Desc