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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Duration between two times

Hello all, I have the following data:

10/01/201923:5101:20
30/02/201913:1216:05
05/01/201922:4003:20
08/02/201917:3120:40

First column is data event, second is start time and thrid is end time. However, using a datediff function, it won't understand that the first line, for example, the start and end time are on different dates, and returns absurd numbers. Also, I don't have a date column referring to the third column, so I don't have 11/01/2019 in the example. Is there anyway to make this work?

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous 

First of all, make sure the two columns are timestamp columns

Else use time function and make them time stamp

 

Start Time = Time(left([Strat],2),right([Strat],2)) // Do same with end

 

My suggestion would make them datetime with date , You can leave  the date part if needed

New columns

Start date time = [Date]+[Start Time]

end Date time = if([Start Time] <[End Time ],[Date]+[EndTime],([Date]+[EndTime])+1)

 

Now you can use date diff

Diff = datediff([Start date time],[end Date time].day)

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@Anonymous 

First of all, make sure the two columns are timestamp columns

Else use time function and make them time stamp

 

Start Time = Time(left([Strat],2),right([Strat],2)) // Do same with end

 

My suggestion would make them datetime with date , You can leave  the date part if needed

New columns

Start date time = [Date]+[Start Time]

end Date time = if([Start Time] <[End Time ],[Date]+[EndTime],([Date]+[EndTime])+1)

 

Now you can use date diff

Diff = datediff([Start date time],[end Date time].day)

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors