Forum Discussion

mifrasmm's avatar
mifrasmm
Helper I
9 years ago
Solved

Calculate Time to Current Time ( DAX )

Hi 

 

I need to create DAX measurement to calculate the timing ( Timer)  from Issued time to current time.

 

 

 

 

  • Hi mifrasmm

     

    The DATEDIFF function will return a number based on the difference between two times in your interval of choice.  In the below example it returns the number of Seconds, but you can chose MINUTES, HOURS, DAYS etc.

     

    NOW() returns the current time to the second.

     

    Seconds = DATEDIFF([Column1],NOW(),SECOND)

5 Replies

  • Hi mifrasmm,

     

    You could try with DATEDIFF method with interval is second. after that convert to format you want: hh:mm:ss by topic

     

    Create calculated column:

     

    Duration in second = DATEDIFF(Sheet1[ISSUED_DATE],NOW(),SECOND)

    Format your timing:

     

    Timer = RIGHT ( "0" & INT (Sheet1[Duration in second] / 3600 ), 2 )
        & ":"
        & RIGHT (
            "0"
                & INT ( (Sheet1[Duration in second] - INT (Sheet1[Duration in second]/ 3600 ) * 3600 ) / 60 ),
            2
        )
        & ":"
        & RIGHT ( "0" & MOD (Sheet1[Duration in second], 3600 ), 2 )

     

     

  • Phil_Seamark's avatar
    Phil_Seamark
    Microsoft Employee

    Hi mifrasmm

     

    The DATEDIFF function will return a number based on the difference between two times in your interval of choice.  In the below example it returns the number of Seconds, but you can chose MINUTES, HOURS, DAYS etc.

     

    NOW() returns the current time to the second.

     

    Seconds = DATEDIFF([Column1],NOW(),SECOND)