March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello, everyone. I've been struggling for a few days to solve an issue involving date/time calculations. If anyone can help me, I'll be grateful.
I have a table called dimTime, which was generated from another table. I have two columns in the date/time format called Start and End. I need to know how many minutes are between the two dates, taking into account the employee's working hours, which are from 08:00:00 to 17:00:00, and excluding Saturdays and Sundays.
Can you help me? I've searched, conducted several simulations, looked in the ChatGPT, and still couldn't find a solution.
I appreciate it in advance.
dimTime
dimHoliday
Productive work interval: 08:00:00 to 17:00:00
Solved! Go to Solution.
Hi, @flaviobdsti
in earlier post it some mistake
as i understood below is your solution
total minute =
var a =
var a1 = FORMAT(TIME(17,00,00)-FORMAT('Table (5)'[start],"hh:MM:ss"),"hh:MM:ss")
var a2 = HOUR(a1)*60 +MINUTE(a1) +(SECOND(a1)/100)
return a2
var b =
var b1 = FORMAT(FORMAT('Table (5)'[end]-TIME(8,00,00),"hh:MM:ss"),"hh:MM:ss")
var b2= HOUR(b1)*60 +MINUTE(b1) +(SECOND(b1)/100)
RETURN b2
var c = a+b
var d=
var d1 =FORMAT('Table (5)'[end]-'Table (5)'[start],"hh:mm:ss")
var d2 = HOUR(d1)*60+MINUTE(d1)+(SECOND(d1)/100)
RETURN d2
var e = NETWORKDAYS('Table (5)'[start],'Table (5)'[end],1,ALL('Table (5)'[holiday]))
var f =c+ ((e-1)*9*60)
RETURN
SWITCH(TRUE(),
e=1,d,
e=2,c,
e>2,f)
Hi, @flaviobdsti
in earlier post it some mistake
as i understood below is your solution
total minute =
var a =
var a1 = FORMAT(TIME(17,00,00)-FORMAT('Table (5)'[start],"hh:MM:ss"),"hh:MM:ss")
var a2 = HOUR(a1)*60 +MINUTE(a1) +(SECOND(a1)/100)
return a2
var b =
var b1 = FORMAT(FORMAT('Table (5)'[end]-TIME(8,00,00),"hh:MM:ss"),"hh:MM:ss")
var b2= HOUR(b1)*60 +MINUTE(b1) +(SECOND(b1)/100)
RETURN b2
var c = a+b
var d=
var d1 =FORMAT('Table (5)'[end]-'Table (5)'[start],"hh:mm:ss")
var d2 = HOUR(d1)*60+MINUTE(d1)+(SECOND(d1)/100)
RETURN d2
var e = NETWORKDAYS('Table (5)'[start],'Table (5)'[end],1,ALL('Table (5)'[holiday]))
var f =c+ ((e-1)*9*60)
RETURN
SWITCH(TRUE(),
e=1,d,
e=2,c,
e>2,f)
Thanks a lot for the help!!!
Thank you for the response; I had already used this function, but it was not enough to solve the problem. The thing is, the NETWORKDAYS function is a function that calculates the number of business days (working days) between two dates, excluding Saturdays and Sundays by default. However, in my case, I need to return the value in minutes and consider a specific range of working hours. With the NETWORKDAYS function alone, I haven't been able to achieve the expected result.
Hi, @flaviobdsti
minute =
var a = NETWORKDAYS('Table (4)'[start],'Table (4)'[end])
var starttime = FORMAT('Table (4)'[start],"hh:mm:ss")
var endtime = FORMAT('Table (4)'[end],"hh:mm:ss")
var _hour = LEFT(FORMAT(endtime-starttime,"hh:mm:ss"),2)*60
var _minute = RIGHT(LEFT(FORMAT(endtime-starttime,"hh:mm:ss"),5),2)
var _second = RIGHT(FORMAT(endtime-starttime,"hh:mm:ss"),2)
var result = _hour +(_minute &"."&_second)
return
result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
115 | |
76 | |
57 | |
52 | |
44 |
User | Count |
---|---|
164 | |
116 | |
63 | |
57 | |
50 |