Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interger to hh:mm:ss format 1

Status
Not open for further replies.

jermine

Programmer
Jun 15, 2001
59
SG
I have an interger that i want to convert into hh:mm:ss format like 00:00:00. is was able to do that using the follwowing code but i know its SO crude.

If LEN(TRIM(Totext(Truncate({AgentStateDaily;1.AvailableTime}/3600),0))) < 2 THEN
FORMULA = &quot;0&quot; + TRIM(Totext(Truncate({AgentStateDaily;1.AvailableTime}/3600),0))
Else
FORMULA = TRIM(Totext(Truncate({AgentStateDaily;1.AvailableTime}/3600),0))
END IF

If LEN(TRIM(ToText(Truncate(Remainder({AgentStateDaily;1.AvailableTime}, 3600)/60),0))) < 2 Then
FORMULA = FORMULA + &quot;:&quot; + &quot;0&quot;+ TRIM(ToText(Truncate(Remainder({AgentStateDaily;1.AvailableTime}, 3600)/60),0))
Else
FORMULA = FORMULA + &quot;:&quot; + TRIM(ToText(Truncate(Remainder({AgentStateDaily;1.AvailableTime}, 3600)/60),0))
END IF

If LEN(TRIM(ToText(Truncate(Remainder ({AgentStateDaily;1.AvailableTime},60 )),0))) < 2 Then
FORMULA = FORMULA + &quot;:&quot; + &quot;0&quot;+ TRIM(ToText(Truncate(Remainder ({AgentStateDaily;1.AvailableTime},60 )),0))
Else
FORMULA = FORMULA + &quot;:&quot; + TRIM(ToText(Truncate(Remainder ({AgentStateDaily;1.AvailableTime},60 )),0))
END IF

IS THERE ANY WAY I CAN DO THIS THE SHORTEST.

Thanks in advance!

 
Hi,

The following formula should produce the same results...

local numbervar n := {your_num_field};
local numbervar h := Truncate(n / 3600);
n := Remainder(n,3600);
local numbervar m := Truncate(n / 60);
local numbervar s := Remainder(n,60);
totext(h,&quot;00&quot;)+&quot;:&quot;+totext(m,&quot;00&quot;)+&quot;:&quot;+totext(s,&quot;00&quot;)

Hth,
Geoff
 


Time(DateAdd('s', aInteger, DateTimeValue(1900,1,1,0,0,0)))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top