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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
NDRS
Frequent Visitor

Calculate hours between two date/time columns and exclude weekends

Hi all, first post here so be nice since im a beginner. 🙏

Im trying to caculate the hours between two columns including start date/time and end date/time and I want to exlude the weekends. I have been looking but many questions is about calculate business hours but that's not the case for me.

Can you guys please help a newbie out? 🙂 Thanks!!

 

NDRS_0-1706774107465.png

 

1 ACCEPTED SOLUTION

you can identify the number of weekends between the 2 dates via the below thread :

https://community.fabric.microsoft.com/t5/Desktop/Calculate-number-of-weekends-Fridays-and-Saturdays...

 

And via datediff get the hours count between the 2 dates and substract the hours based on number of weekends * 24




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

View solution in original post

4 REPLIES 4
NDRS
Frequent Visitor

Thanks for the reply.

Each row is basicly a ticket with a start and end-date/time (Opened and solved) and I want to calculate the number of hours it takes so solve every ticket. And by weekend I mean I want to exclude the hours from saturday and sunday since we are not measured in the SLA on the weekends.  Make this more sense now?

 

Im familiar with the DATEDIFF formula but if a ticket is opened on a friday and solved on a monday, it will include the hours from the weekend and I don't want it to include the hours from the weekend. 

you can identify the number of weekends between the 2 dates via the below thread :

https://community.fabric.microsoft.com/t5/Desktop/Calculate-number-of-weekends-Fridays-and-Saturdays...

 

And via datediff get the hours count between the 2 dates and substract the hours based on number of weekends * 24




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Thanks! Great way to solve it.
I used this formula:

Custom = DATEDIFF('MyTable'[Start date],'MyTable'[End date],HOUR) -
COUNTROWS(FILTER(CALENDAR('MyTable'[Start date],'MyTable'[End date]), WEEKDAY([Date],2) in {6,7} )) * 24

NDRS_0-1706790276418.png

 






NandanHegde
Super User
Super User

You can identify whether a date is weekday or weekend bbbby below aspect :

if(WEEKDAY([Date],2)>=6,"Weekend","Weekday")

 

And you can use DATEDIFF to identify the diff in hours between 2 dates:

https://datascientest.com/en/mastering-power-bi-datediff-effortlessly-calculate-time-intervals#:~:te....

 

 

Can you also plz state what you mean by exclude weekends




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.