cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Re: How to add hours to DateTime data?

THIS FUNCTION IS AVAILABLE BY direct query?????

 

I have this error

 

modelo_CONEXION_bdXOOM - Power BI Desktop.jpg

Highlighted
Resolver IV
Resolver IV

Re: How to add hours to DateTime data?

Not trying to resurrect a dead topic, but for those wondering where #duration is.. it's in PowerQuery (M), not DAX.

Dan Malagari
Consultant at Headspring
Highlighted
Frequent Visitor

Re: How to add hours to DateTime data?

Thansk a lot, your solution worked magically for my issue as well 🙂

Highlighted
Advocate I
Advocate I

Re: How to add hours to DateTime data?

You can do this in a calculated column if you prefer not to delve in to M.

 

The default unit in a Date/Time context is 1 day, so:

 

Column = [DateTimeCreated] + 1  in your example would return 2016-12-21 19:40

 

You can use this to add hours using decimals or a calculation like:

 

Column = [DateTimeCreated] + 0.5  (12 hours added)

 

Column = [DateTimeCreated] + ((1/24)*10)  (10 hours added)

 

Highlighted
Helper I
Helper I

Re: How to add hours to DateTime data?

thanks you just helped me too!!

Highlighted
Frequent Visitor

Re: How to add hours to DateTime data?

It works! Amazing and thanks


@steve_honey wrote:

You can do this in a calculated column if you prefer not to delve in to M.

 

The default unit in a Date/Time context is 1 day, so:

 

Column = [DateTimeCreated] + 1  in your example would return 2016-12-21 19:40

 

You can use this to add hours using decimals or a calculation like:

 

Column = [DateTimeCreated] + 0.5  (12 hours added)

 

Column = [DateTimeCreated] + ((1/24)*10)  (10 hours added)

 



!

Highlighted
Helper II
Helper II

Re: How to add hours to DateTime data?

This accepted solution works for integers, but not for decimals.

 

If you wish to support decimals as well, then you should convert the value to second and round it:

DateTimeValue = DateTimeValue + #duration(0,0,0,Number.Round(DaysToShift * 24 * 3600))

 

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors