How to convert hours minutes seconds

I have 3 int tags that I want to combine in to a memory tag. To display in this format HH:MM:SS. How would I go about doing this? expression tag? etc

I would use the setTime function. You could pass it now() for the initial value then pass your three integer tags to specify hour,minute, and second. I would utilize an expression tag to do this.

using Dint’s not ints to show downtime in HH:MM:SS

A simpler method may be to make a string expression tag with the following expression.

Str(HourTag) + β€˜:’ + str(MinutesTag) + β€˜:’ + str(SecondsTag)

You may want to introduce some if then logic to add a zero to the front if they are single digit. You could use the following check for any of the three.

If(len(str(HourTag)) == 1,’0’ + str(HourTag),str(HourTag))

1 Like

I ended up doing it like this

toString({[.]DowntimeHours}) + β€˜:’ + // Hour
toString({[.]DowntimeMinutes}) + β€˜:’ + // Min
toString({[.]DowntimeSeconds}) //Sec

Is there a way to trend this data?