Countif Not Counting Left Date

itchdog

New Member
Joined
Sep 14, 2014
Messages
2
Hi.

I'm using a left function to get the hour from a cell that contains a date, and then using COUNTIF to get a total of how many columns match that hour:

UC.Data!M2: 9/9/14 6:13 PM
C2: =UC.Data!M2
G2: =LEFT(HOUR(C2),2)
I2: =COUNTIF(G2,">9")

G2 displays "18" in the cell (left 2 of 1800). The COUNTIF in I2 should return a 1 because 18 is greater than 9. Am I doing something wrong?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
What happens if you just use HOUR(C2)?
 
Upvote 0
As Norrie suggested, =HOUR(C2) will give you 18...IF your cell contains a real date/time combo, and not just text looking like date/time
 
Upvote 0
Well I'll be! It works that way. Is there a reason the countif didn't see the 18 with the left(hour(c2),2) function?

Thanks for the quick response.
 
Upvote 0
LEFT would be converting the numeric hour to a string, which could be the problem.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,942
Members
449,094
Latest member
teemeren

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top