Convert integer to time

Solved!
dembangom1
Level 1
Convert integer to time
Hello, is it possible please DSS to convert an integer 0448 in the form 04: 48?
0 Kudos
1 Solution
Clรฉment_Stenac
Hi,

You can do that with a formula: http://doc.dataiku.com/dss/latest/advanced/formula.html

If your string always has the leading 0, then you can use:

strval(input_column).substring(0, 1) + ":" + strval(input_column).substring(2,3)

Else, you can use:

if (input_column < 1000, "0" + strval(input_column).substring(0, 0) + ":" + strval(input_column).substring(2,3), strval(input_column).substring(0, 1) + ":" + strval(input_column).substring(2,3))

(if num value is below 1000 then add the 0 manually, else use regular formatting)

View solution in original post

0 Kudos
2 Replies
Clรฉment_Stenac
Hi,

You can do that with a formula: http://doc.dataiku.com/dss/latest/advanced/formula.html

If your string always has the leading 0, then you can use:

strval(input_column).substring(0, 1) + ":" + strval(input_column).substring(2,3)

Else, you can use:

if (input_column < 1000, "0" + strval(input_column).substring(0, 0) + ":" + strval(input_column).substring(2,3), strval(input_column).substring(0, 1) + ":" + strval(input_column).substring(2,3))

(if num value is below 1000 then add the 0 manually, else use regular formatting)
0 Kudos
dembangom1
Level 1
Author
Thank you I found thanks to your help.
0 Kudos