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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Digadumm
Frequent Visitor

Calculating duration from two timestamps based on schedule

Hi!

I have two date/time columns defining Start and End -times. What I need is to get a duration -info based on following schedules:


DaySchedule = 08:00-22:00
NightSchedule=22:00-08:00

 

so as an example:

 

StartTime= 1.1.2019 21:30
EndTime= 2.1.2019 03:30


Result should be shown so that I have a duration from those timestamps for daytime and nighttime in own columns - like

 

DayTime=30 minutes
NightTime= 5h 30 minutes


Is there an easy way to do this?

 

 

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@Digadumm 

 

You may download the file attached and check the steps in Query Editor.

 

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi!

 

That seem to work - almost. Only issue is that I have actually also seconds on my timestamps, so in some cases that causes a negative value as a result to nighttime - as you see on the example below. How to correct that one?Capture.PNG

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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