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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Nitin03
Frequent Visitor

How to find difference between two dates in hours.

Hi
I am new to Dax. I want find difference between two dates in hours. I tried by using DATEDIFF function but it is excluding minutes
11.png
I want result like this
1.png
Is there another way to solve this probem. 
@amitchandak 

1 ACCEPTED SOLUTION

Hi,

You need to calc the Hour and Minutes separately, then add the particular text Hr and Min to the text one. 

use the below code for your measure :

DateDiffInHour = CONCATENATE(
                             CONCATENATE(
                                         DATEDIFF( values(Sheet244[In Time]), values(Sheet244[Out Time]),hour)
                                         , " hr ")
                             ,
                             CONCATENATE(  mod( DATEDIFF( values(Sheet244[In Time]), values(Sheet244[Out Time]), minute), 60)," min")
                            )
MahyarTF_0-1667343132240.png

 

Mahyartf

View solution in original post

3 REPLIES 3
Nitin03
Frequent Visitor

Hi @MahyarTF  I have already tried by using datediff I want ans like this :
1.png

Hi,

You need to calc the Hour and Minutes separately, then add the particular text Hr and Min to the text one. 

use the below code for your measure :

DateDiffInHour = CONCATENATE(
                             CONCATENATE(
                                         DATEDIFF( values(Sheet244[In Time]), values(Sheet244[Out Time]),hour)
                                         , " hr ")
                             ,
                             CONCATENATE(  mod( DATEDIFF( values(Sheet244[In Time]), values(Sheet244[Out Time]), minute), 60)," min")
                            )
MahyarTF_0-1667343132240.png

 

Mahyartf
MahyarTF
Memorable Member
Memorable Member

Hi 

did you use the Interval in your dax :

DateDiffInHour = DATEDIFF( values(Sheet244[In Time]), values(Sheet244[Out Time]),HOUR)

MahyarTF_0-1667291274571.png

Appreciate your Kudos and please mark my response as a solution if it helps you

Mahyartf

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!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

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