0

I execute the following command in SQL Server 2008 and it does not give me the desired results.

 RTRIM(avg(ProcTime)/3600) + ':'  + RIGHT(('0'+RTRIM(avg(MTD_ProcTime) % 3600) / 60),2)   

Let's say I get 2:5 instead of 2:05, it drops the zero. How do I get that zero in front of the 5 ?

1
  • Can you state what you're doing and that what 2:5 or 2:05 means. Also what does ProcTime & MTD_ProcTime contain. Commented Jun 6, 2013 at 0:45

2 Answers 2

1

try

RTRIM(avg(ProcTime)/3600) + ':'  + RIGHT(('0'+RTRIM(avg(MTD_ProcTime) % 3600 / 60)),2)

I moved the ) from after 3600 to after 60

Sign up to request clarification or add additional context in comments.

Comments

0

What you want is the two zeros in your RIGHT(('00'+ ... function, like this:

RTRIM(avg(ProcTime)/3600) + ':'  + 
RIGHT(('00'+RTRIM(avg(MTD_ProcTime) % 3600) / 60),2)

That way you end up with right 2 chars of 00N, or 0N.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.