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

How to calculate hours and minutes difference from now

Hi

 

I have a table that shows when were our machines data updated in format:
09.10.2020 08:10:22
Now I need a new column that shows hold old this is from now. Since it's 8:51 o'clock atm it should give me value:
00:41:15

Tried this but it gives me wrong values:

Diff = DATEDIFF(TODAY(),'POS LaneCurrentState'[LastTransactionDate],MINUTE)

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous ,

Try like

Diff = DATEDIFF(Now(),'POS LaneCurrentState'[LastTransactionDate],MINUTE)
or
Diff = DATEDIFF('POS LaneCurrentState'[LastTransactionDate],Now(),MINUTE)
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
Anonymous
Not applicable

Thanks this gives me answer in minutes that I can work with but I also need to be able to do this in M code now.
Tried:
Duration.ToText(DateTime.FixedLocalNow - [LastTransactionDate])
but that doesn't work either:

Expression.Error: We cannot apply operator - to types Function and DateTime.
Details:
    Operator=-
    Left=[Function]
    Right=09.10.2020 08:19:19

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.