I have an expression for a custom message of an alarm that looks like this:
if(left({State}, 5) = "Clear"
,
"- '{name}' on '{displayPath}' went out of alarm at " + getHour12(now()) + ":" + getMinute(now()) + ":" + getSecond(now()) + " " + if(getAMorPM(now()) = 1, "PM", "AM") + "."
,
"- '{name}' on '{displayPath}' went into alarm at " + getHour12(now()) + ":" + getMinute(now()) + ":" + getSecond(now()) + " " + if(getAMorPM(now()) = 1, "PM", "AM") + ". " + "\n" +
" Drive Fault: " + {[.]LastFault} + " - " + {[.]LastFaultName})
I am doing this to include tag values in the email. This works great except when the minutes or seconds are less than ten. The time can end up looking something like this:
4:5:2 PM
Obviously, this does not look good. Is there a better way to grab the time part of now()? Is there a different way to do what I am doing?