Reporting Services custom code

  • I am trying to convert hours to days inside reporting services ... so in my report it displays 25 hours... which the user wants to see 1.1 days... can anyone help... thanks


    Moe C

  • Moe,

    I don't know if this is what you are looking for but here is what I use.

    In VS.Net on data tab....

     CONVERT(numeric(9, 2), dbo.Table.Field / 8) AS Days

    Hope that helps,

    Kerrie

  • Try this as your field expression:

    =((Fields!hours.Value-Fields!hours.Value Mod 24) / 24) + (Fields!hours.Value Mod 24)/10

    Changing the field name as appropriate, obviously

  • Sorry just realised the above won't work for all values, will post back when I've worked it out

  • Try this instead:

    =(Fields!hours.Value-Fields!hours.Value Mod 24)/24 & "." & (Fields!hours.Value Mod 24)

     

  • thanks... i will use this and see what happens...


    Moe C

  • I tried the solution above and sorry it does not come up with it correctly... so in my SP i have 2 dates i do a datediff on ... i call it totaltime ... well then i have to take the difference between that time and divide it by the number of application came in between the time period to get the average time... so say the average time it took was 25 hours... well they customer wants to see instead of 25 hours on the report they want to see 1 day 1 hours...  


    Moe C

  • Only a slight modification of my previous code required then:

    =(Fields!hours.Value-Fields!hours.Value Mod 24)/24 & " days " & (Fields!hours.Value Mod 24) & " hours "

    should do it.

  • here is a sample from my code

    =IIF(Fields!TotalApplications.Value = 0,"-",IIF(Fields!TotalReturnTime.Value / Fields!TotalApplications.Value = 0,"-",Format(Fields!TotalReturnTime.Value / Fields!TotalApplications.Value,"N1")& " days" ) )

    but the problem i am running into is when when the its 25 hours.. it should display 1 day 1 hour... so the above would not work...


    Moe C

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply