You can use the following formula if the data meets some of the prerequisites:
- Login / Logout must be in pairs
- In terms of time Login must be before Logout
- Login / Logout must be within a day
I edited your sample data to get correct result.
To get list of dates use array formula:
=IFERROR(INDEX(INT($A$2:$A$21),MATCH(1,--(COUNTIF($D$1:D1,INT($A$2:$A$21))=0),0)),"")
Array formula after editing is confirmed by pressing ctrl
+ shift
+ enter
to calculate hours use:
=SUMPRODUCT($A$2:$A$21*(D2=INT($A$2:$A$21))*("logout"=$B$2:$B$21)-$A$2:$A$21*(D2=INT($A$2:$A$21))*("login"=$B$2:$B$21))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…