Ray_Dooley_108

Automic Script to convert seconds to HH:MM:SS format

Discussion created by Ray_Dooley_108 on Oct 9, 2013
Latest reply on Mar 17, 2014 by Mark_Hadler_430
This example converts the Statistics Duration which is returned in seconds to HH:MM:SS readable format but could be used for any situation where this type of conversion is required. :set &sss = GET_STATISIC_DETAIL(&UC_CAUSE_NR,DURATION) :define &f_hrs#,float :define &f_min#,float :define &s_hrs#,string :define &s_min#,string :define &u_hrs#,unsigned :define &u_min#,unsigned ! Hours :set &f_hrs# = DIV(&sss,3600) :set &s_hrs# = CONVERT(string,&f_hrs#) :set &pt# = STR_FIND(&s_hrs#,".") :set &pt# = SUB(&pt#,2) :set &u_hrs# = MID(&s_hrs#,2,&pt#) ! Minutes :set &xhrs# = MULT(&u_hrs#,3600) :set &tmp# = SUB(&sss,&xhrs#) :set &f_min# = DIV(&tmp#,60) :set &s_min# = CONVERT(string,&f_min#) :set &pt# = STR_FIND(&s_min#,".") :set &pt# = SUB(&pt#,2) :set &u_min# = MID(&s_min#,2,&pt#) ! Seconds :set &xmin# = MULT(&u_min#,60) :set &xhrmn# = ADD(&xhrs#,&xmin#) :set &sec# = SUB(&sss,&xhrmn#) ! Format results :set &s_hrs# = FORMAT(&s_hrs#,'00') :set &s_min# = FORMAT(&s_min#,'00') :set &sec# = FORMAT(&sec#,'00') :set &runtime# = &s_hrs#:&s_min#:&sec# :print Elapsed Time: &runtime#

Outcomes