Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Calcular tiempo transcurrido considerando solo el horario laboral

Tengo un query que registra requerimientos de mantenimiento, algo parecido a la tabla muestra. Lo que necesito es calcular el tiempo transcurrido entre Created_Date y AssignedDate; AssignedDate y End_Date. El inconveniente está, en que necesito que se calcule solmente el horario laboral cuando una tarea tome mas de un dia en finalizarse, es decir, que se haga un corte de tiempo y se reanude al dia siguiente. El horario laboral es de 7:00 am a 4:30 pm. Sé que podría hacerlo con un condicionante pero si solo fuese un dia el que transcurre, no se me ocurre cómo hacerlo si el reporte permanece abierto mas de un dia.

 

 

IdCreated_DateRequested_ByAssignedDateTentative_DateEnd_DateTechnicianStatusDelay_date
18557/1/2022 9:32Empleado 17/1/2022 12:567/4/2022 0:007/1/2022 13:46Mecanico 1Finalizado 
18567/1/2022 15:32Empleado 27/2/2022 16:217/4/2022 0:007/5/2022 10:53Mecanico 2Finalizado 
18577/4/2022 7:17Empleado 37/4/2022 8:477/4/2022 0:007/4/2022 13:55Mecanico 3Finalizado 
18587/4/2022 7:20Empleado 47/4/2022 8:467/4/2022 0:007/4/2022 15:57Mecanico 4Finalizado 
18597/4/2022 8:42Empleado 57/4/2022 8:467/4/2022 0:007/4/2022 15:58Mecanico 5Finalizado 
18607/4/2022 9:07Empleado 67/4/2022 11:117/9/2022 0:007/20/2022 9:00Mecanico 6Finalizado 
18617/4/2022 9:27Empleado 77/5/2022 10:237/4/2022 0:007/4/2022 13:55Mecanico 7Finalizado 
18627/4/2022 9:28Empleado 87/5/2022 10:237/5/2022 0:007/4/2022 15:58Mecanico 8Finalizado 
18637/4/2022 9:42Empleado 97/4/2022 10:227/4/2022 0:007/4/2022 14:01Mecanico 9Finalizado 
18647/4/2022 11:13Empleado 107/4/2022 11:227/5/2022 0:007/5/2022 10:54Mecanico 10Finalizado 
2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @Anonymous 

 

You can try the following methods.

Difference1 = 
Var _SECOND=DATEDIFF([Created_Date],[AssignedDate],SECOND)
Return
FORMAT ( ROUNDDOWN ( DIVIDE ( _SECOND, 3600 ), 0 ), "00" ) & ":"
        & FORMAT ( ROUNDDOWN ( DIVIDE ( MOD ( _SECOND, 3600 ), 60 ), 0 ), "00" ) & ":"
        & FORMAT ( MOD ( _SECOND, 60 ), "00" )
Difference2 = 
Var _SECOND=DATEDIFF([AssignedDate],[End_Date],SECOND)
Return
FORMAT ( ROUNDDOWN ( DIVIDE ( _SECOND, 3600 ), 0 ), "00" ) & ":"
        & FORMAT ( ROUNDDOWN ( DIVIDE ( MOD ( _SECOND, 3600 ), 60 ), 0 ), "00" ) & ":"
        & FORMAT ( MOD ( _SECOND, 60 ), "00" )

vzhangti_0-1670479673820.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @v-zhangti thanks, but what I need is to make a count of elapsed time but only for working hours, from 7:00 am to 4:30 pm. If the task is not completed on one day I need to make a cut of time for a time value >4:30 pm to <7:00 am, for each day till the task is completed. Also, I forgot to add that I need to exclude weekends as well

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.