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

Be 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

Reply
Anonymous
Not applicable

how to get hours and minutes between dates

 

Hi,

 

I have two fields start Date_time and End Date_Time, i want to calculate hours and mintures spend between two dates, kindly advise how to calculate total time in hours and minutes.

 

 Start Time End Time WorkingHours
11/6/2017 9:30      11/6/2017 11:30 0
11/6/2017 12:00   11/6/2017 13:30 0
11/6/2017 14:30   11/6/2017 17:30 0
11/6/2017 17:31   11/6/2017 18:00 0
11/7/2017 9:00     11/7/2017 10:00 0
11/6/2017 9:00     11/6/2017 18:00 0
11/6/2017 22:00 11/7/2017 7:00 0
11/7/2017 22:00 11/8/2017 1:30 0
11/6/2017 9:30 11/7/2017 13:00

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable
Anonymous
Not applicable


@Anonymous wrote:

 

@Anonymous,

Perhaps this post can help you: https://community.powerbi.com/t5/Desktop/Calculating-day-time-difference/m-p/321189


 

As mentioned in the above post, Duration.ToRecord([EndTime]-[StartTime]) also handles the requirement perfectly in QueryEditor, whereas DATEDIFF is DAX.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Also can use a measure, i feel little faster loading time with this 

TimeDiff = CONVERT(SELECTEDVALUE(Table[Date1],0)-SELECTEDVALUE(Table[Date2],0),DATETIME)

and then change the format to time hh:mm:ss


Cheers

Anonymous
Not applicable

Hi

 

The below formula will get you the hour difference between the two datetime value. By changing the last parameter to HOUR/ MINUTE/SECOND , you can get the desired result.

 

HrDiff = DATEDIFF(Table1[StartTime],Table1[EndTime],HOUR)

HrDiff = DATEDIFF(Table1[StartTime],Table1[EndTime],MINUTE)

 

Thanks
Raj

Anonymous
Not applicable

Hello Everybody,

Please I need your comment and advice on this data.

Have been having issues with this data. The data is for the month of September 2021. But when I upload it into power bi it brings a date dated 1899. I have tried all efforts to change my locale in the settings but the error persists.

 

OPERATING TIMETarget HOURSDaysDATEOPENING TIMECLOSING TIMEOPERATING TIMEOVER HOURS
6am-7pm13:00:00Wednesday1-Sep7:0018:5511:550:00
6am-7pm13:00:00Thursday2-Sep7:1018:5511:450:00
6am-7pm13:00:00Friday3-Sep7:1018:5511:450:00
0.000:00:00Saturday4-Sep8:0510:252:202:20
0.000:00:00Sunday5-Sep11:4019:057:257:25
6am-7pm13:00:00Monday6-Sep7:1018:5511:450:00
6am-7pm13:00:00Tuesday7-Sep7:1018:5511:450:00
Anonymous
Not applicable


@Anonymous wrote:

 

@Anonymous,

Perhaps this post can help you: https://community.powerbi.com/t5/Desktop/Calculating-day-time-difference/m-p/321189


 

As mentioned in the above post, Duration.ToRecord([EndTime]-[StartTime]) also handles the requirement perfectly in QueryEditor, whereas DATEDIFF is DAX.

Anonymous
Not applicable

Hi,

 

If i use MINUTE, it give result as 30,60,180,210,119,104 and

if i use HOURS, it 30 minutes utilized it say 1, 1.5 say 2.

 

how is poosible to calculate hours and minutes altogether for example if 140 minutes it should say 2:10 Hrs.

 

Pls guide.

Thx

Anonymous
Not applicable

As mentioned in the above post, Duration.ToRecord([EndTime]-[StartTime]) also handles the requirement perfectly in QueryEditor, You will get the difference in Hr, Min, Sec in different columns, you can concatenate Hrs and Mins column to get the desired result.

Hope this helps!

 

Thanks

Raj

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.