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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
hsparg008
Frequent Visitor

Finding Working Hours Between Two Dates

I'm trying to find the number of working hours between two dates. I have a start and end date. Right now, I'm finding the number of working days between the dates and then multiplying it by the hours in the work day, but this is resulting in some rounding error (i.e. 4.3 days is rounded to 4 days). Is there a way to get a fraction of a day or calculate the working hours outright?

 

Working Hours -- 1st Shift is Monday to Friday 8 hours/day

2nd Shift is Monday to Thursday 10 hours/day -- only certain entries have a second shift

 

Right now I'm finding the 1st shift working days and the 2nd shift working days separately and then adding them together.

 

I have some of the DAX used in calculated columns below for reference. Are there any suggestions?

 

1. Find the number of first shift working days for an entry. It's the same for second shift but <=4

VAR MyDates
ADDCOLUMNS(
GENERATESERIES([Status Start Time]+1, [Status End Time]),
"Day", WEEKDAY([Value],2) // 1= Monday and 7 = Sunday
)
RETURN
COUNTROWS(FILTER(MyDates,[Day] <= 5)) //<= 5 means the weekday is monday through friday
2. Add the 1st shift and 2nd shift days to find the total working hours
Past Month Hours Duration =
'Historical Tech Center Submissions'[First Shift Days Past Month]*8 + 'Historical Tech Center Submissions'[Second Shift Days Past Month]*10
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @hsparg008 ,

 

A new DAX used to return the number of workdays between date range. It always returns whole number.

 

NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>])

 

NETWORKDAYS function (DAX) - DAX | Microsoft Docs

 

Best Regards

Community Support Team _ chenwu zhu

 

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

View solution in original post

2 REPLIES 2
v-chenwuz-msft
Community Support
Community Support

Hi @hsparg008 ,

 

A new DAX used to return the number of workdays between date range. It always returns whole number.

 

NETWORKDAYS(<start_date>, <end_date>[, <weekend>, <holidays>])

 

NETWORKDAYS function (DAX) - DAX | Microsoft Docs

 

Best Regards

Community Support Team _ chenwu zhu

 

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

daXtreme
Solution Sage
Solution Sage

@hsparg008 

 

If you turn a date/time into a number (say, you multiply it by 1.0), it'll give you a number. On such numbers you can carry out arithmetic to obtain durations in (fractional) days. Check this out:

 

EVALUATE
var dt = convert("2020-12-10 14:20:12", DATETIME)
return
    {(1.0 * dt, dt)}

 

Run this in DAX Studio as is.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.