Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 Convert to Hour:Min in Expression

Author  Topic 

nikoo56
Starting Member

26 Posts

Posted - 2012-03-15 : 14:17:38
I have this expression that return number like 320,

Avg(Fields!final_rep_response1.Value)

How I can write an expression the way that shows 300 as Hour:Minutes

like: 5:19

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-03-15 : 15:11:25
Something along the lines of:
CStr(Fix(Avg(Fields!final_rep_response1.Value)/60)) & ":" & CStr(Avg(Fields!final_rep_response1.Value) Mod 60)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-15 : 16:00:51
are you trying to do this in report or in sql?

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=172481

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

nikoo56
Starting Member

26 Posts

Posted - 2012-03-15 : 19:53:45

How I can round it to 2 digits. This is returning: 3.22222 I like to return for example: 3.22


quote:
Originally posted by sunitabeck

Something along the lines of:
CStr(Fix(Avg(Fields!final_rep_response1.Value)/60)) & ":" & CStr(Avg(Fields!final_rep_response1.Value) Mod 60)


Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-03-15 : 22:48:38
quote:
Originally posted by nikoo56


How I can round it to 2 digits. This is returning: 3.22222 I like to return for example: 3.22


quote:
Originally posted by sunitabeck

Something along the lines of:
CStr(Fix(Avg(Fields!final_rep_response1.Value)/60)) & ":" & CStr(Avg(Fields!final_rep_response1.Value) Mod 60)





use Round() function
CStr(Fix(Avg(Fields!final_rep_response1.Value)/60)) & ":" & CStr(Round(Avg(Fields!final_rep_response1.Value) Mod 60,2))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -