cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bourne2000
Helper V
Helper V

How to calculate the time difference between date and time?

Hi

 

I have two problems. My data source is a CSV file. It has two columns called BookingStart and BookingEnd

 

bourne2000_0-1642464238642.png

 

1) My first problem when I imported my CSV file into Power BI and date and time is mismatching as below

 

bourne2000_1-1642464293388.png

For example, the first-row actual booing date is 16.11.2021 but it shows 17.11.2021. Also, the time is 13:08 pm but it shows 2.08 am. Can anyone advise how to fix this?

 

2) My second problem,

 

I need to create a new minutes column between booking end time and booking start time. I can able to add columns and subtract in the Power query. But the average minute's values are not matching properly. It's not recognizing am/pm properly.

Can anyone help with this?

 

Thanks

 

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@bourne2000 for 2nd one, use duration.totalminutes function

 

Duration.TotalMinutes ( [Start Column] - [End Column] )

 

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

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts 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.






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.





View solution in original post

4 REPLIES 4
parry2k
Super User
Super User

@bourne2000 for 2nd one, use duration.totalminutes function

 

Duration.TotalMinutes ( [Start Column] - [End Column] )

 

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

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts 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.






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.





parry2k
Super User
Super User

@bourne2000 can you change the type from date time to time zone and then in the next step-change it to datetime. let's first check that.

 

 






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.





@parry2k  Thanks

 

When I converted into timezone

 

bourne2000_0-1642465338406.png

 

 

However when I tried to convert back to date/time, the values are changing

 

bourne2000_1-1642465368245.png

 

Please advise

@parry2k It's working thanks. I just extracted time into separate columns

 

bourne2000_0-1642465653281.png

 

 

Can you advise my second question. If I do subtract, then I am getting negative values. I need to create total hour column and total minutes column from the end and start date

Helpful resources

Announcements
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!