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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
pang22
Helper II
Helper II

Add hours in Power Query

Hi 

 

How to create a column and add 8 hours to the time in Power Query?

4/26/2024 7:19:04 AM   -->  4/26/2024 3:19:04 PM  

pang22_0-1714123767866.png

 

1 ACCEPTED SOLUTION
v-jingzhan-msft
Community Support
Community Support

Hi @pang22 

 

You can add a custom column with below code. Use #duration(0,8,0,0) to add 8 hours to a datetime value. #duration - PowerQuery M | Microsoft Learn

[TrackingTime] + #duration(0,8,0,0)

vjingzhanmsft_1-1714355099313.png

 

@AnalyticsWizard Thanks for the prompt reply. To my knowledge Power Query doesn't have Date.AddHours function.

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

View solution in original post

2 REPLIES 2
v-jingzhan-msft
Community Support
Community Support

Hi @pang22 

 

You can add a custom column with below code. Use #duration(0,8,0,0) to add 8 hours to a datetime value. #duration - PowerQuery M | Microsoft Learn

[TrackingTime] + #duration(0,8,0,0)

vjingzhanmsft_1-1714355099313.png

 

@AnalyticsWizard Thanks for the prompt reply. To my knowledge Power Query doesn't have Date.AddHours function.

 

Best Regards,
Jing
If this post helps, please Accept it as Solution to help other members find it. Appreciate your Kudos!

AnalyticsWizard
Solution Supplier
Solution Supplier

@pang22 

 

In Power Query, you can create a new column that adds 8 hours to a datetime column by using the "Date.AddHours" function. Here’s how you can do it:

 

1. Click on the column that contains the datetime you want to adjust.
2. Go to the "Add Column" tab in the Power Query editor.
3. Choose "Custom Column" from the menu to open the "Add Custom Column" dialog.
4. In the new column formula area, enter a formula like this:

 

= Date.AddHours([TrackingTime], 8 )

 

Replace `[TrackingTime]` with the actual name of your column if it’s different.

5. Give your new column a name, such as "AdjustedTime".
6. Click "OK" to add the new column.

 

This will create a new column with each datetime value increased by 8 hours. After you’ve done this, remember to apply your changes and load the data back into Power BI if you're working from there.

 

If this post helps, please consider Accepting it as the solution to help the other members find it more quickly. Appreciate your Kudo 👍

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.