cancel
Showing results 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.

Helper I

Add integer (minutes) to datetime

Hello guys,

I need to add an integer to a datetime to get the final date (date time format)

I have the start date column and the duration in minutes as an integer. I need datetime format as output (final date)

Any ideas on this?

Thanks,

Thiago

1 ACCEPTED SOLUTION
Super User
``New Time1 = MAX('Table'[Time]) + MAX('Table'[Integers])/24/60``

Hi @ThiagoDuarte Try  this.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

11 REPLIES 11
Super User

New column = [Start Date] + time(0,[Duration(Minute]), 0)

Helper I

it doesn't work

the column duration minutes have values over 3000

Super User

Hi @ThiagoDuarte Try

``[Time]+#duration(0,0,[Integers],0)``

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Super User

Hi @ThiagoDuarte

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Helper I

It does work but i cant use it with direct query.

i need a directquery solution

Super User

hi @ThiagoDuarte , you did not mention direct query in your  question...but you can you use Number.Mod(5, 3) = (2 as an example.) Divide the integers by 60, then the modulus by 60 until less than 60 etc.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Super User

Hi @ThiagoDuarte ,
What if you did this with DAX not in PowerQuery?
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Helper I

That was my first tought.

I tried doing this on dax but i couldn't get it to work properly

``````var tap = reportfusion[Tap to Tap]  (this is a measure. it sums a few columns)

//inicial
var iniciohora = HOUR(MAX(reportfusion[start date]))
var iniciominuto = MINUTE(MAX(reportfusion[start date]))
var iniciodia = INT(MAX(reportfusion[start date]))
var iniciosegundo = SECOND(MAX(reportfusion[start date]))

//duração
var duracaohora = INT(divide(tap,60))
var duracaominuto = int(reportfusion[Tap to Tap])
var duracaodia = INT(DIVIDE(tap,1440))

//final
var finaldia = convert(iniciodia+duracaodia,DATETIME)
var finalhora = mod(iniciohora+duracaohora,24)+int(divide(duracaominuto,60))
var finalminuto = mod(iniciominuto+duracaominuto,60)

//data final
var dia = DATE(YEAR(finaldia),MONTH(finaldia),day(finaldia))
var hora = IF(LEN(finalhora)=1,0&finalhora,finalhora)
var minuto = IF(LEN(finalminuto)=1,0&finalminuto,finalminuto)

var datafinal = dia&" "&hora&":"&minuto&":"&iniciosegundo
return
datafinal``````

Super User
``New Time1 = MAX('Table'[Time]) + MAX('Table'[Integers])/24/60``

Hi @ThiagoDuarte Try  this.

Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Helper I

Ok. That worked beautifully

Thank you so much!

Super User

Hi @ThiagoDuarte

I never do that!🤣

Nathaniel

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Announcements

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

Power BI Monthly Update - April 2024

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

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors