How to ad leading 0s
I have a column called minutes and that can range from 0 - 60, what I'm trying to do is add a leading 0 to the single digit values,
ex 9 = 09, so that no matter what my value is always 2 digits long, is that possible? and if so, how would I accomplish that?
Operating system used: windows
Answers
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
You have not responded to my answer in your other thread which seems to be related to this. Perhaps you are trying to calculate the difference between two dates and display the result in hh:mm:ss format? This 6 year old post shows how to do that.
-
That formula didnt work for me
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
You need to make sure you don't break the formula lines in the wrong place. Try with this text which uses a code block and should add extra line breaks:
"00"[0,2-(floor(diff(last_working_day, Date_parsed, "seconds")/3600)).length()] + (floor(diff(last_working_day, Date_parsed, "seconds")/3600)) + ':' + "00"[0,2- (floor(mod(diff(last_working_day, Date_parsed, "seconds"), 3600)/60)).length()] + (floor(mod(diff(last_working_day, Date_parsed, "seconds"), 3600)/60)) + ':' + "00"[0,2- (mod(mod(diff(last_working_day, Date_parsed, "seconds"), 3600),60)).length()] + (mod(mod(diff(last_working_day, Date_parsed, "seconds"), 3600),60))
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
Also this formula can add leading zeros as required:
concat(("00" + Hours).substring(-2), ":", ("00" + Minutes).substring(-2))