Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
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)
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.