• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Error while counting the timestamp

saravana

New Member
I am getting an error while counting the timestamp between
06:00 to 17:59 and 18:00 to 05:59 (like morning and night shift report)

am using like

got the correct answer
COUNTIFS($A:$A,$E$3,$B:$B,">=06:00",$B:$B,"<=17:59")
COUNTIFS($A:$A,$E$4,$B:$B,">=06:00",$B:$B,"<=17:59")

its showing error
COUNTIFS($A:$A,$E$3,$B:$B,">=18:00",$B:$B,"<=05:59")
COUNTIFS($A:$A,$E$4,$B:$B,">=18:00",$B:$B,"<=05:59")

I've attached the sample Doc for reference,Kindly do a needful.

Thanks!
 

Attachments

  • error timestamp.xlsx
    17.9 KB · Views: 5
might be
=COUNTIFS($A:$A,$E5,$B:$B,">=18:00")+COUNTIFS($A:$A,$E5,$B:$B,"<=05:59")

Since there are no dates, there is no logic before/past midnight.
 

Attachments

  • Copy of error timestamp.xlsx
    18.1 KB · Views: 3
Conditions in COUNTIFS is considered "AND" condition. Therefore, it must satisfy all criteria. However, time cannot satisfy both being >=18:00 & <=5:59.

To avoid this you must either use addition (OR condition) as Grah - Guido has shown above. Which I'd recommend for readability and performance.

Or use other formula construct. Such as SUM(IF(Conditions,1,0)) array formula or Sumproduct formula.

Ex:
=SUMPRODUCT(($A$4:$A$387=E5)*($B$4:$B$387>=TIME(18,0,0))+($A$4:$A$387=E5)*($B$4:$B$387<TIME(6,0,0)))
 
saravana
... almost same as above
... can time be same time after 18:00 and before 06:00 ... ?
 

Attachments

  • error timestamp.xlsx
    18.6 KB · Views: 5
Back
Top