cancel
Showing results 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

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.

2 REPLIES 2
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" )``````

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

Announcements

#### 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.

#### Power BI Monthly Update - February 2024

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

#### Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

#### Microsoft Fabric Partner Community

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

Top Solution Authors
Top Kudoed Authors