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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

datetime difference in datetime format

Hi there !

 

A123Chauhan_0-1654692397590.png

 

I am trying to find the diff b/w these 2 columns . The output should be in datetime. 

Ultimate goal is to show  time difference as x days y hours z minutes w seconds format as the difference.

 

Is there a DAX function available for the same ?

DATEDIFF only gives one value based on HOUR, MINUTES, SECONDS that needs to be modified to finally achieve the above goal.

 

Can anyone help me with this?

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

You need to create multiple calculated columns to obtain results at each time granularities, and then concatenate the results.

Duration in Seconds = DATEDIFF('Table'[Datetime1],'Table'[Datetime2],SECOND)
_day = INT('Table'[Duration in Seconds]/(3600*24))
_hour = INT( MOD('Table'[Duration in Seconds],(3600*24))/3600)
_minute = INT(MOD(MOD('Table'[Duration in Seconds],(3600*24)),3600 )/60)
_second = MOD(MOD(MOD('Table'[Duration in Seconds],(3600*24)),3600 ),60)
diff = 'Table'[_day] &" days "&'Table'[_hour]&" hours "&'Table'[_minute]&" minutes "&'Table'[_second]&" seconds"

Result:

veasonfmsft_0-1655199609053.png

 

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

View solution in original post

2 REPLIES 2
v-easonf-msft
Community Support
Community Support

Hi, @Anonymous 

You need to create multiple calculated columns to obtain results at each time granularities, and then concatenate the results.

Duration in Seconds = DATEDIFF('Table'[Datetime1],'Table'[Datetime2],SECOND)
_day = INT('Table'[Duration in Seconds]/(3600*24))
_hour = INT( MOD('Table'[Duration in Seconds],(3600*24))/3600)
_minute = INT(MOD(MOD('Table'[Duration in Seconds],(3600*24)),3600 )/60)
_second = MOD(MOD(MOD('Table'[Duration in Seconds],(3600*24)),3600 ),60)
diff = 'Table'[_day] &" days "&'Table'[_hour]&" hours "&'Table'[_minute]&" minutes "&'Table'[_second]&" seconds"

Result:

veasonfmsft_0-1655199609053.png

 

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

mh2587
Super User
Super User

Referring to this thread
https://community.powerbi.com/t5/Desktop/Calculating-day-time-difference/m-p/321189


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.