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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
What happens if you just use HOUR(C2)?
 
Upvote 0

FDibbins

Well-known Member
Joined
Feb 16, 2013
Messages
6,723
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

itchdog

New Member
Joined
Sep 14, 2014
Messages
2
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

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,358
Office Version
  1. 365
Platform
  1. Windows
LEFT would be converting the numeric hour to a string, which could be the problem.
 
Upvote 0

Forum statistics

Threads
1,191,177
Messages
5,985,140
Members
439,942
Latest member
bkexcel11230

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
Top