Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
I have Free PBI Desktop v2.105 (64 bit free version May 2022) on 64-bit Windows Server. I have 4 fields in a table called NonChargeTime: startdate, starttime, enddate, endtime. In power query the startdate and enddate are both of type Date. Starttime and enddtime are both of type Time.
When I try to make a measure using DATEDIFF PBI won't let me enter any date field. How do I calculate the difference in hours between these 2 times? It's possible the dates are different. I thought it would work like this:
Measure = DATEDIFF(startdate & " " & TIME(starttime), enddate & " " TIME(enddtime),HOUR)
And this wouldn't let me enter the date field either: Measure = DATEDIFF(DATEVALUE(startdate)...
Ex:
Startdate: 7/1/2022
Starttime: 11:00:00 PM
Enddate: 7/2/2022
Endtime: 1:00:00 AM
The difference is 2 hours.
More example data:
Startdate: 7/14/2022
Starttime: 8:00:00 AM
Enddate: 7/14/2022
Endtime: 5:00:00 PM
Duration is 9 hours in this case.
The data comes from an ODBC connection to a Postgresql database, so I assume PBI converts the date fields to a DATE datatype, and I'm not sure what the time fields (a string in Postgresql) would be converted to in PBI. This worked fine in tutorials I watched but it doesn't work for me.
Is DATEDIFF even the right function for me to use?
Can anyone help out please? Thank you.
-----
I have solved this. This is how I did it.
Hours = DATEDIFF(StartDateTime, EndDateTime, MINUTE)/60
Solved! Go to Solution.
DATEDIFF is the right function to use.
My suggestion is to user PowerQuery to merge the Date and Hour together in one column (StartDateHour and EndDateHour).
Then you can do something like DATEDIFF(StartDateHour, EndDateHour, HOUR)
DATEDIFF is the right function to use.
My suggestion is to user PowerQuery to merge the Date and Hour together in one column (StartDateHour and EndDateHour).
Then you can do something like DATEDIFF(StartDateHour, EndDateHour, HOUR)
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 23 | |
| 21 | |
| 20 | |
| 19 | |
| 13 |
| User | Count |
|---|---|
| 58 | |
| 50 | |
| 38 | |
| 31 | |
| 27 |