The query below in datediff
is bringing the days difference correctly, but I only want to bring the amount of working days.
I already have a working day function that excludes Saturdays, Sundays and holidays.
But I'm having trouble putting this function in the query below in datediff
. How do I?
SELECT UC.UsuRazaoSocial [Cliente - Razão Social],
UC.UsuNome [Cliente - Nome Fantasia],
T.TarID [Tarefa],
T.TarTitulo [Título],
MAX(CONVERT(DATE,A.AtivData,103)) [Data Última Providência],
T.TarNumAtiv [Número da Providência],
S.StatusDesc [Status],
DATEDIFF(DAY,MAX(A.AtivData),GETDATE()) Dias
FROM Tarefa T
LEFT JOIN Usuario UC ON UC.UsuID = T.UsuIDCliente
LEFT JOIN Atividade A ON A.TarID = T.TarID
LEFT JOIN Status S ON S.CodStatus = T.TarStatus
WHERE T.ProjID IS NOT NULL
GROUP BY UC.UsuRazaoSocial,
UC.UsuNome,
T.TarID,
T.TarTitulo,
T.TarNumAtiv,
S.StatusDesc
ORDER BY UC.UsuRazaoSocial