3 Replies Latest reply on Feb 14, 2012 10:22 AM by shilpa g

    Calculations

    shilpa g

      Hi Folks,

      I m new to tableau and in the phase of learning and exploring.

       

      I have two datetime fileds,

      1. Prev_update_time

      2. update_time

       

      i want to calculate the difference between these two fields. I tried to use datetime func using

      datetime(prev_update_time) - datetime(update_time)

       

      looks like this gives wrong results when seen.

       

      please help!

       

      Thanks much.

        • 1. Re: Calculations
          Jun Kim

          Hi,

           

          You might want to try using the DATEDIFF Function:

           

          DateDiff('hour', [Prev_update_time], [update_time])

           

          you can change the bold to the level of time you want the difference for.  There are other options for calculating the difference between 2 datetime fields. 

           

          It might help, if you could tell us what format your fields are in and what result you expect after finding the difference.

           

          thanks,

          Jun

          • 2. Re: Calculations
            shilpa g

            Thank you so much for your reply.

            The two columns in datetime data type are as below.

             

            01/01/2012 1:55:45

            01/01/2012 1:40:20

             

            when i subtract these two datetime fileds it gives me a floating point number like 0.010 (not an exact value)

             

            the requirement is to show the in terms of days, hrs , min and seconds... like 0 days, 0 hrs , 10 min and 25 secs.

             

            Please let me know . Thanks

            • 3. Re: Calculations
              shilpa g

              Thanks

              I am able to achieve the result in the required format by using datediff func and then concatenating the calulated fileds,

               

              I m finding the result in this format

              -30days-799hr-47886min-

               

              I mite need to convert in 12 hr and 60 min format. Also a hypen - appears though i have nt hardcoded it.

               

              Please help