0
I need to average the time it takes since creation (a. Date of creation) until completion (s. Data_status_finalized) field.
Not able to count weekends and holidays.
The following query is working, however, takes into account every day of the period.
SELECT AVG(DATEDIFF(HH, a.Data_Criacao, s.Data_Status_Finalizado))
FROM RTRC_Processo p
Left join RTRC_Solucao s on (s.Id_Processo_RTRC = p.Id )
Left Join RTRC_Abertura a on (a.Id_Processo_RTRC = p.Id)
WHERE 1=1
and s.Status ='F'
AND p.Data_Exclusao is null
and YEAR(s.Data_Status_Finalizado) = 2019
and MONTH(s.Data_Status_Finalizado)= 08
Which one
SGBD
?– Sorack
Sqlserver. ....
– Danielle Arruda torres
Possible duplicate of Working day function
– Sorack
Possible duplicate of Doubt SQL Working Days Query
– rLinhares
In the article The holiday table and calendar creation with working days in SQL Server you can find various ways to treat holidays and working days. ->https://portosql.wordpress.com/2020/12/14/tabela-calendario-feriados-diasutel/
– José Diz