Hola a todos!
Tengo una pregunta requiero convertir una cantidad de segundos a formato de hhmmss, tengo la siguiente formula
concat(
ifelse(floor((({Segment Duration Seconds}) / 3600)) < 10,
concat(‘0’, tostring(floor((({Segment Duration Seconds}) / 3600)))),
tostring(floor((({Segment Duration Seconds}) / 3600)))
),
‘:’,
ifelse(floor((({Segment Duration Seconds}) % 3600) / 60) < 10,
concat(‘0’, tostring(floor((({Segment Duration Seconds}) % 3600) / 60))),
tostring(floor((({Segment Duration Seconds}) % 3600) / 60))
),
‘:’,
ifelse((({Segment Duration Seconds}) % 60) < 10,
concat(‘0’, tostring((({Segment Duration Seconds}) % 60))),
tostring((({Segment Duration Seconds}) % 60))
)
)
pero la parte de la hora me queda como con un residuo, tengo este ejemplo
el resultado debería ser 17:31:32 pero me sale “479” no logro quitarlo
me podrian ayudar
1 Like
Hi @Santi98
The formula looks mostly correct for converting seconds into an HH:MM:SS format, but let’s optimize it and ensure it handles cases correctly.
-
Parentheses and Operator Precedence: Ensure that division and modulus operations are correctly grouped with parentheses to avoid calculation errors.
-
Ensure the field is consistently numeric and doesn’t have unexpected decimals.
Try the below formula
concat(
ifelse(floor(({Segment Duration Seconds}) / 3600) < 10,
concat('0', tostring(floor(({Segment Duration Seconds}) / 3600))),
tostring(floor(({Segment Duration Seconds}) / 3600))
),
':',
ifelse(floor(({Segment Duration Seconds}) % 3600 / 60) < 10,
concat('0', tostring(floor(({Segment Duration Seconds}) % 3600 / 60))),
tostring(floor(({Segment Duration Seconds}) % 3600 / 60))
),
':',
ifelse(({Segment Duration Seconds}) % 60 < 10,
concat('0', tostring(({Segment Duration Seconds}) % 60)),
tostring(({Segment Duration Seconds}) % 60)
)
)
1 Like
hola @Xclipse, tuve que generar el cambio desde la Base de Datos, porque no funciono en QS, de igual forma gracias por la ayuda!