Converting an Integer to Time

Hello,
Not sure how to go about this or if it is even possible. I have an integer tag that I am using from a 3rd party OPC Server (Kepware) that I am needing in Time Format. The value reads “124554” which is correct. I just need it to display 12:45:54. Can this be done. Thanks in advance.

Sure. Replace all instances of valueSourceTag with the path to your integer tag.

if({valueSourceTag} >= 100000,
	// Use left two digits for hours for times 10:00:00 or greater.
	left({valueSourceTag}, 2) + ":" + substring({valueSourceTag}, 2, 4),
	// Use only 1 left digit for hours for times less than 10:00:00.
	left({valueSourceTag}, 1) + ":" + substring({valueSourceTag}, 1, 3)
)
+ ":" + right({valueSourceTag}, 2)

Thank you. Thats just what I needed. Worked perfectly!

1 Like

A couple other options:

groupConcat(split({Root Container.Numeric Text Field.intValue}, "(?<=\\G.{2})"), "parts", ":")`
concat(
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} / 10000), "00"
	),
	":",
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} % 10000 / 100), "00"
	),
	":",
	numberFormat(
		floor({Root Container.Numeric Text Field.intValue} % 100), "00"
	)
)