Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Days and hour between two dates

I Wish calculate NetWorkingDays with hours for attached sheet. 

 

 

Sample Data 

  • Hi Anonymous ,

    Use the Start date and Close date as an example, you can create a calculated column like this to calculate the diff:

    Diff = 
    VAR _totalminutes =
        DATEDIFF ( 'Table'[Start Date], 'Table'[Close Date], MINUTE )
    VAR _minutes =
        MOD ( _totalminutes, 60 )
    VAR _hours =
        MOD ( DIVIDE ( _totalminutes - _minutes, 60 ), 24 )
    VAR _days =
        DIVIDE ( _totalminutes - _minutes - _hours * 60, 24 * 60 )
    RETURN
        _days & " days " & _hours & ":" & _minutes

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

3 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Amit,

       

       

      Thanks fo your quick response but i would like to also calculate hours as well with days between tose two dates

      i have tried below calculated column

      NetWorkDaysHoursMinutes =
      VAR Calendar1 = CALENDAR(MAX(Request_Summary[RT.Act Completion Date]),MAX(Request_Summary[RT.Est Completion Date]))
      VAR Calendar2 = ADDCOLUMNS(Calendar1,"WeekDay",WEEKDAY([Date],2))
      RETURN COUNTX(FILTER(Calendar2,[WeekDay]<5),[Date]) & " Days " & HOUR(MOD(MAX(Request_Summary[RT.Act Completion Date]) - MAX(Request_Summary[RT.Est Completion Date]),1)) & " Hours " & MINUTE(MOD(MAX(Request_Summary[RT.Act Completion Date]) - MAX(Request_Summary[RT.Est Completion Date]),1)) & " Minutes" 

      Please help me with same

      If possible

  • v-yingjl's avatar
    v-yingjl
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

    Use the Start date and Close date as an example, you can create a calculated column like this to calculate the diff:

    Diff = 
    VAR _totalminutes =
        DATEDIFF ( 'Table'[Start Date], 'Table'[Close Date], MINUTE )
    VAR _minutes =
        MOD ( _totalminutes, 60 )
    VAR _hours =
        MOD ( DIVIDE ( _totalminutes - _minutes, 60 ), 24 )
    VAR _days =
        DIVIDE ( _totalminutes - _minutes - _hours * 60, 24 * 60 )
    RETURN
        _days & " days " & _hours & ":" & _minutes

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.