Forum Discussion
Anonymous
3 years agoNot applicable
Calculate working time between 2 timestamp in difference day
Hello, I'm newbie here please let me know if i miss anything. I want to calculate working time (minute) between 2 timestamps but not count time if it not in working hour (9.00 - 18.00) the da...
- Anonymous3 years ago
Hi Anonymous ,
I suggest you to try this code to create a calcualted column.
Processing time (Min) = VAR _DAYDIFF = DATEDIFF ( 'Table'[Time A], 'Table'[Time B], DAY ) VAR _REST_MIN = ( 6 + 9 ) * 60 VAR _STARTDATE = IF ( TIMEVALUE ( 'Table'[Time A] ) < TIME ( 9, 0, 0 ), DATEVALUE ( 'Table'[Time A] ) + TIME ( 9, 0, 0 ), IF ( TIMEVALUE ( 'Table'[Time A] ) > TIME ( 18, 0, 0 ), DATEVALUE ( 'Table'[Time A] ) + TIME ( 18, 0, 0 ), 'Table'[Time A] ) ) VAR _ENDDATE = IF ( TIMEVALUE ( 'Table'[Time B] ) < TIME ( 9, 0, 0 ), DATEVALUE ( 'Table'[Time B] ) + TIME ( 9, 0, 0 ), IF ( TIMEVALUE ( 'Table'[Time B] ) > TIME ( 18, 0, 0 ), DATEVALUE ( 'Table'[Time B] ) + TIME ( 18, 0, 0 ), 'Table'[Time B] ) ) VAR _PROCESSTIME1 = DATEDIFF ( _STARTDATE, _ENDDATE, MINUTE ) RETURN _PROCESSTIME1 - _REST_MIN * _DAYDIFFResult is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi Anonymous
It worked totally Perfect!
I'm really appreciated and Thank you very much your help Master.