0
The query below in datediff
is bringing the difference of days correctly, but I just want to bring the amount of working days.
I already have a business day function that excludes Saturdays, Sundays and holidays.
However I am having difficulties to put this function in the consultation below in datediff
. How do I do?
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
If understood well you want to know the difference from one date to another on working days, correct?
– Marconi
This question is not duplicated with its other two that are not yet closed?
– Sorack
@Sorack, I just closed up, but here it’s different.
– Renan Bessa
Correctly @Marconi
– Renan Bessa
@Renanbessa, include the function
dias uteis
in the question.– Marconi
@Renanbessa Here are options that calculate correctly: Operating with working days on SQL Server -> https://portosql.wordpress.com/2020/12/02/operando-dias-uteis/
– José Diz