I'm hoping the SQL gurus can spot what the the problem is with the following SQL statement. It works but the time is off by 1 hour. For example, if the node is down for 15 minutes, the down time is reported as 1 hour 15 min. Does anyone see what the problem is and what is needed to fix it? I'm not very SQL savvy and got the datetime conversion from another post. What am I missing?
SELECT StatusLED
, NodeID
, Caption
, Status
, DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), LastSystemUpTimePollUtc) AS LastSystemUpTimePoll
,convert(varchar(10), (DATEDIFF(d,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), LastSystemUpTimePollUtc),GETDATE()))) + ' Days ' +
convert(varchar(10), (DATEDIFF(hh,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), LastSystemUpTimePollUtc),GETDATE())% 24 )) + ' Hours '+convert(varchar(10), (DATEDIFF(mi,DATEADD(mi, DATEDIFF(mi, GETUTCDATE(), GETDATE()), LastSystemUpTimePollUtc),GETDATE()) % 60)) + ' Mins ' as 'DD:HH:MM:SS'
From Nodes
WHERE StatusLED = 'down.gif'
ORDER BY 6 desc