Days and Hours

  • Is there a way in reporting services to display 1 day and 1 hour instead of 25 hours OR 1.1 days ... thanks


    Moe C

  • The better way of handling this would be on the SQL, to retrieve the day and hours in the desired format.

     

    Prasad Bhogadi
    www.inforaise.com

  • DECLARE @Hours INT

    SET @Hours = 25

    SELECT CAST((@Hours/24) AS VARCHAR) + ' Day(s) ' + CAST ((@Hours % 24) AS VARCHAR) + ' Hour(s)' AS DateValue

     

    Prasad Bhogadi
    www.inforaise.com

  • Are you starting with an integer number of hours, a DATEDIFF, the DaysInterval property, or what? 

    IAC if you can't do this on the SQL side, as others have explained, you can of course use VB functions that would do the equivalent on the reporting side. 

     

    Is your problem that you don't know the exact expression to use? If so, if it is an integer, there is probably a more elegant StringFormat way (VB is not my thing), but this would do it:

    CStr

    (System.Math.Round(theInteger / 24, 0)) & " days, " & CStr(theInteger Mod 24) & " hours"

  • Im using in the SQL side a datediff in hours ...


    Moe C

  • If you're using an integer that's a DateDiff, then the VB expression I gave you should work.  No? Am I misunderstanding the question?

    >L<

Viewing 6 posts - 1 through 5 (of 5 total)

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