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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

display negative time with parenthesis 1

Status
Not open for further replies.

bluraz

MIS
Aug 18, 2005
32
US
Hi! I am working with Crystal IX and am working with the following formula....


NumberVar nbrTime := {@test};
NumberVar nbrHour := Truncate(nbrTime);
NumberVar nbrHold := (nbrTime-nbrHour)*100;
nbrHold := (60*nbrHold)/100;
NumberVar nbrMinute := Truncate(nbrHold);
nbrHold:= (nbrHold-nbrMinute)*100;
NumberVar nbrSecond := Truncate(nbrHold*60)/100;

ToText(nbrHour,0,"") + ":" + ToText(nbrMinute,0,"") + ":" + ToText(nbrSecond,0,"")

Some of the time results come out negative as they should and display as "-4:-39:-17".

What do I need to do to display the time as (4:39:17) whenever the result is negative.

Any help would be greatly appreciated!! Thanks in advance.

bluraz
 
Cheat it with:

NumberVar nbrTime := {@test};
NumberVar nbrHour := Truncate(nbrTime);
NumberVar nbrHold := (nbrTime-nbrHour)*100;
nbrHold := (60*nbrHold)/100;
NumberVar nbrMinute := Truncate(nbrHold);
nbrHold:= (nbrHold-nbrMinute)*100;
NumberVar nbrSecond := Truncate(nbrHold*60)/100;
stringvar Output :=
ToText(nbrHour,0,"") + ":" + ToText(nbrMinute,0,"") + ":" + ToText(nbrSecond,0,"");
if instr(Output,"-") > 0 then
"(" & replace(Output,"-","") & ")"
else
Output

-k
 
Perfect... Just what I was needing!!

Thanks you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top