Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Time to integer, and vice versa

Hi all,

 

I have a report where I want a measure that returns the amount of seconds, to be converted to "HH:MM:SS". In the same report for another measure I want a "HH:MM:SS" column to be converted to the ammount of seconds in it as a integer. 

 

Best regards,

L.Meijdam

  • Seconds number to Time string:

          =FORMAT( [seconds] / 60 / 60 /24, "hh:nn:ss" )

     

    Time string to Seconds number:

          =TIMEVALUE( [time str] ) * 24 * 60 * 60

     

     

6 Replies

  • Seconds number to Time string:

          =FORMAT( [seconds] / 60 / 60 /24, "hh:nn:ss" )

     

    Time string to Seconds number:

          =TIMEVALUE( [time str] ) * 24 * 60 * 60

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi DAX0110,

       

      The "string to seconds number" is working like expected thankyou very much!

       

      The other calculation is giving me a error, although I don't think the formula is incorrect. I want a calculated column that is in "Whole number" format to change the amount of seconds to a time value. But when I use your formula it returns: Cannot convert value '' of type Text to type Date. And I don't really understand why since it is in "Whole number" format.

       

      My calculated column

      Best regards,

      L.Meijdam

      • DAX0110's avatar
        DAX0110
        Resolver V

        Mmm, that's interesting.  In my test workbook the Power Pivot "seconds" column is "decimal" type with "general" format.

         

        If you feed the output column from "string to seconds number" into the "seconds number to string" formula, it should work (I did that to double check my formula).