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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
shei7141
Helper III
Helper III

POWER BI - DATEIFF IN CORRECT RESULTS

Hi

 

I have two columns (startDateTime) and (EndDateTime) and I wanted to get the difference between two dates. My data format is as follows:

StartDateTime = 7/01/2011 3:31:00 PM

EndDateTime = 12/01/2011 8:44:00 AM

I created a column called differnce = DATEDIFF(File1[StartDateTime],File1[EndDateTime],HOUR)

I am getting a result = 3665

I changed the formula of difference to DATEDIFF(File1[StartDateTime],File1[EndDateTime],DAY)

than I am getting the result = 153

 

The answer should be 113hours (i.e. rounded down). I checked this in excel and it is giving me the right result.

Can someone please assist me with.

I am not sure what is going on. I even tried a simple subtraction but the result is still 153hours.

 

Thanks

Shei

2 REPLIES 2
parry2k
Super User
Super User

@shei7141 the reason for this is that it converted your raw dates into:

 

July 1st, 2011 and Dec 01st, 2011 whereas you are doing the calculation assuming following 

 

Jan 07th, 2011, and Jan 12th, 2011 and that's how the number of hours turned out to be 113.

 

You need to make your culture in change data type is set to dd/mm/yyyy rather mm/dd/yyyy

 

and that's the underline issue.

 

 

Follow us on LinkedIn and YouTube.gif to our YouTube channel

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make effort to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Ashish_Mathur
Super User
Super User

Hi,

Between January 1, 2011 and December 1, 2022 there are 153 days.  What is the problem?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.