Forum Discussion

admi's avatar
admi
Frequent Visitor
6 years ago

Time between date

Hi,

 

I need to get the time in minutes between two dates like this : 13/02/2020 17:04.00. The first and the last of my table.

I also need to calculate the time when a parameters is null. I have a column for the date and another for the parameters.

 

Thanks for your help

16 Replies

  •  

    Total Time Diff = 
    
    VAR StartDate = MIN( 'Table'[StartDate] )
    VAR EndDate = MAX( 'Table'[EndDate] )
    
    RETURN
    
    DATEDIFF( StartDate , EndDate , MINUTE )

     

     

    Give it a thumbs up! 😃

  • Hi admi ,

     

    The difference between 2 dates in Minutes can be calculated by creating a column as follows:

     

    DateDiffMinutes = DATEDIF(date1, date2, minute)

     

    In the above formual, just replace "date1" & "date2" with your date columns.

     

    Thanks.

  • az38's avatar
    az38
    Community Champion

    admi 

    what do you mean "parameters" is null?

    above solutions are good, but it could change the rule

    • Anonymous's avatar
      Anonymous
      Not applicable

      If you want column then use below dax.

       

      Column=datediff(Date1,Date2,Minute)

       

      If you want dynamic values as per slicers create measure.

       

      Measure=Datadiff(Min(Table[Date1]),Min(Table[Date2]),minute)

       

      Thanks & regards,
      Pravin Wattamwar
      www.linkedin.com/in/pravin-p-wattamwar

      If I resolve your problem Mark it as a solution and give kudos.

       

       

       

    • admi's avatar
      admi
      Frequent Visitor

      Hi,

       

      By null, I mean '0'.

       

      Thanks

      • az38's avatar
        az38
        Community Champion

        admi 

        how do you want o calculate this 0? as current date?

        if so, try to use modificated AlexAlberga727 solution

        Total Time Diff = 
        
        VAR StartDate = MIN( 'Table'[StartDate] )
        VAR EndDate = IF(EndDate = 0, TODAY(), MAX( 'Table'[EndDate] ))
        
        RETURN
        
        DATEDIFF( StartDate , EndDate , MINUTE )