String Format to show decimal up to 2 places

Hi - I have a message box at the end of a workflow to display total elapsed time but I want to truncate the milliseconds.

TimerObj - is the variable I assigned for Start & Stop Timer. In the expression builder I used string.format(“{0:00}”,TimerObj.Elapsed.TotalMinutes.ToString).

I want to display the results like MM:SS and when the workflow runs currently it displays “0.083649005”.

How can I make it instead display “0.08”?

TIA

Try with String.Format("0.00", TimerObj.Elapsed.TotalMinutes.ToString)

Hi @marian.platonov - thanks but the result was “0.00” using
string.format(“0.00”,TimerObj.Elapsed.TotalMinutes.ToString).

Any other suggestions? Getting closer!

In this case, try this solution:

  1. Set the TimerObj.Elapsed.TotalMinutes to System.Double
  2. Then use this expression String.Format("{0:0.00}", TimeValue)

Example:

Hi @UI_SF ,
Try below options
double num
Convert.ToDouble(String.Format(“{0:0.00}”, num))
or
String.Format(“{0:0.00}”, 123.4567)
or

double source = 1234.56789; // 1234.57
result = source.ToString("F2")

Regards,
Arivu

@marian.platonov Success! Thank you! This seemed like such a simple formatting task that I had not considered changing the variable type. For anyone else struggling with the same, I did the following in StudioX:

Remember: change the TimeValue variable to System.Double in Properties:
image
image

@arivu96 thank you!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.