I have the following query that produces a number of results for me. One of which is the number of days old each of the records is.
I need a more accurate figure now by removing weekends from the equation. Not sure how to proceed and struggling to understand answers I have found. My query so far is:
select
i.incidentnumber,
i.priority,
i.status,
i.subject,
i.actualsystem,
t.ownerteam,
convert(varchar,i.createddatetime,103)[Created],
convert(varchar,i.lastmoddatetime,103)[Modified],
datediff(day,i.createddatetime,{fn now()})[Days old],
datediff(mi,i.createddatetime,{fn now()})[Minutes old],
cast(i.createddatetime
i.owner
from
incident i with (nolock) inner join task t with (nolock) on t.parentlink_recid = i.recid
where
i.status <> 'Closed'
and i.actualsystem <> 'System Administration'
--and i.service <> 'Service Request'
and t.status in ('Active','Waiting','Accepted')
--and t.ownerteam <> 'UK Service Desk'
order by
--t.ownerteam asc
--i.actualsystem asc
datediff(day,i.createddatetime,{fn now()}) desc
I am using SQL server manager and querying a 2005 database. I comment out as necessary. The minutes old is a new column added today. Can anyone help?