cancel
Showing results for
Did you mean:
Visitor

## Calculate time between clock in and clock out (no date info)

I'm trying to calculate how many Minutes there are between an employee's clock in and out time (in that order) to get total minutes worked. My formula: Minutes Worked = ABS(DATEDIFF('TA Data'[Clock In],'TA Data'[Clock Out],MINUTE)). It returns the correct minutes worked when Clock in time is in the AM and clock out is in the PM (see figure 1 below). However, there is no date information attached to these times so when clock in is in the PM and clock out is in the Am minutes worked ends up being calculated wrong (see figure 2 below). What formula do I need to use to calculate time from clock in until clock out, in that order?

Figure 1: shows correct working minutes

Figure 2: shows incorrect working minutes. The highlighted example should show 595 actual working minutes (minutes between clock in and clock out time). Without date information it is counting minutes from clock out (AM) until clock in (PM) and showing 845 minutes.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super Contributor

## Re: Calculate time between clock in and clock out (no date info)

Hi @Bezzen

You may try to create below columns:

```Hour =
IF (
'TA Data'[Clock in] < 'TA Data'[Clock Out],
ABS ( DATEDIFF ( 'TA Data'[Clock in], 'TA Data'[Clock Out], HOUR ) ),
24 - HOUR ( 'TA Data'[Clock in] )
+ HOUR ( 'TA Data'[Clock Out] )
)```
```Minute =
VAR a =
HOUR ( 'TA Data'[Clock Out] ) * 60
+ MINUTE ( 'TA Data'[Clock Out] )
VAR b =
( 24 - HOUR ( 'TA Data'[Clock in] ) )
* 60
- MINUTE ( 'TA Data'[Clock in] )
RETURN
IF (
'TA Data'[Clock in] < 'TA Data'[Clock Out],
ABS ( DATEDIFF ( 'TA Data'[Clock in], 'TA Data'[Clock Out], MINUTE ) ),
a + b
) ```

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Super Contributor

## Re: Calculate time between clock in and clock out (no date info)

Hi @Bezzen

You may try to create below columns:

```Hour =
IF (
'TA Data'[Clock in] < 'TA Data'[Clock Out],
ABS ( DATEDIFF ( 'TA Data'[Clock in], 'TA Data'[Clock Out], HOUR ) ),
24 - HOUR ( 'TA Data'[Clock in] )
+ HOUR ( 'TA Data'[Clock Out] )
)```
```Minute =
VAR a =
HOUR ( 'TA Data'[Clock Out] ) * 60
+ MINUTE ( 'TA Data'[Clock Out] )
VAR b =
( 24 - HOUR ( 'TA Data'[Clock in] ) )
* 60
- MINUTE ( 'TA Data'[Clock in] )
RETURN
IF (
'TA Data'[Clock in] < 'TA Data'[Clock Out],
ABS ( DATEDIFF ( 'TA Data'[Clock in], 'TA Data'[Clock Out], MINUTE ) ),
a + b
) ```

Regards,

Cherie

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

Announcements

#### Back to School Contest

Engage and empower students with Power BI!

#### Watch Sessions On Demand!

Continue your learning in our online communities.

#### Summit Australia 2019

Travel to Melbourne and network with thousands of peers!

Top Ideas
Top Kudoed Authors
Users Online
Currently online: 212 members 2,381 guests
Recent signins: