Forum Discussion
ThiagoDuarte
Helper I
4 years agoAdd 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 fo...
- 4 years ago
New Time1 = MAX('Table'[Time]) + MAX('Table'[Integers])/24/60Hi 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
Nathaniel_C
Community Champion
4 years agoHi ThiagoDuarte ,
What if you did this with DAX not in PowerQuery?
Nathaniel
ThiagoDuarte
Helper I
4 years agoThat 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
- ThiagoDuarte4 years ago
Helper I
Ok. That worked beautifully
I was overthinking about this hehe 😅
Thank you so much!
- Nathaniel_C4 years ago
Community Champion
New Time1 = MAX('Table'[Time]) + MAX('Table'[Integers])/24/60Hi 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 - Nathaniel_C4 years ago
Community Champion
Hi ThiagoDuarte
I never do that!🤣
Nathaniel