Help with COUNTIFS formula when counting dates that include a time

UpToTheGills

New Member
Joined
Aug 26, 2022
Messages
38
Office Version
  1. 2019
Platform
  1. MacOS
Morning all,

I am attempting to use COUNTIFS to total the number of trades for a particular month on a different worksheet but the formula I have used just returns a zero. I wondering if that is because I need to take account of the dates to count also include the time?

Excel Formula:
=COUNTIFS('IC Live 4004xxxx'!$B$3:$B$353,">="&C5,'IC Live 4004xxxx'!$B$3:$B$353,"<="&EOMONTH(C5,0))

I can't figure out what is incorrect about the above formula… 🤔

The dates that I want to count appear formatted as below:
Screenshot 2022-09-02 at 10.25.42.png


Thank you for any assistance.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
whats in C5 ?
does that have a time
other wise should not matter as the time is a decimal - so if c5 is 1/2/22
44593

then any time is greater
so 1/2/22 at 9:00 is
44593.375

but if C5 has a time , then that will make a difference
also are the cells real dates in B, if you format as general do they stay as dates or change to numbers, if stay as dates then they are text

i have reformatted C5 and B3 s general to show the date/time asa number - so you can see what i mean

=COUNTIFS($B$3:$B$353,">="&C5,$B$3:$B$353,"<="&EOMONTH(C5,0))

also changed to exclude the sheet name - so you can see it work on one sheet

test11.xlsx
ABC
15
2
344593.375
42/3/22 10:00
52/4/22 0:0044593
62/5/22 0:00
72/6/22 0:00
Sheet2
Cell Formulas
RangeFormula
A1A1=COUNTIFS($B$3:$B$353,">="&C5,$B$3:$B$353,"<="&EOMONTH(C5,0))



Note: Images are difficult to see , and also requires that I input all the data myself, which is very time consuming.

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC , then put the sample spreadsheet onto a share
I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed
 
Upvote 0
Thanks for your reply.

No C5 is simply formatted as MMM YYYY, with the cell containing 01/05/2022:

Screenshot 2022-09-02 at 11.13.37.png
 
Upvote 0
sorry i edited my my post above - what about B
have a reread
 
Upvote 0
Yes, I was trying to google a solution and came across this YouTube video which made the distinction for cells that contain both the date and time since the date is the integer before the decimal point and the time is after the decimal point.

Thanks - let me look at your suggestion.
 
Upvote 0
yes thats true
BUT

if you have 1/2/22 in cell b5 - then that is an integer of 44593 - just a number

then you say
($B$3:$B$353,">="&C5

so 1/2/22 at 9:00 is 44593.375
which is greater and so it should count it
as i have shown in the example posted

there are a lot of situations where the time does matter and then you use

INT(date cell)
or if you are counting time say and the cell is time but shows 1/1/1900 - which often happens - you need to remove the INT
so
date cell - Int(date cell) to just get the decimal part as 0.xxxxx

not been able to watch video - as about to leave for the day
 
Upvote 0
Thanks - I am trying to look at installing the XL2BB addin...

So, my formula looks correct yet is returning zero?

Excel Formula:
=COUNTIFS('IC Live 4004xxxx'!$D$3:$D$353,">="&C5,'IC Live 4004xxxx'!$D$3:$D$353,"<="&EOMONTH(C5,0))

(I changed the lookup range to column D from column B)
 
Upvote 0
As you have time values the last part of the formula should be
Excel Formula:
"<"&Eomonth(C5,0)+1
(or use Edate) otherwise anything on the last day will not be counted.
If you change the format for the whole of col D to General do you see numbers or dates?
 
Upvote 0
Solution
TradingJournal.xlsm
BCDEFGHI
3Month / YearGain on A/cTotal No. of trades
4
5May 20220
6Jun 2022
7Jul 2022
Stats Overview
Cell Formulas
RangeFormula
H5H5=COUNTIFS('IC Live 4004xxxx'!$D$3:$D$353,">="&C5,'IC Live 4004xxxx'!$D$3:$D$353,"<="&EOMONTH(C5,0))
 
Upvote 0
TradingJournal.xlsm
BCD
30306-Jun 00:2706-Jun 00:4305-Jun 22:27
30403-Jun 00:3403-Jun 13:2502-Jun 22:34
30501-Jun 21:1401-Jun 23:2701-Jun 19:14
30601-Jun 21:0601-Jun 21:1201-Jun 19:06
30701-Jun 20:1201-Jun 20:2201-Jun 18:12
30830-May 23:3131-May 00:1330-May 21:31
30929-May 17:0529-May 19:2129-May 15:05
31028-May 22:0029-May 15:0628-May 20:00
31126-May 20:0827-May 07:4326-May 18:08
31225-May 00:0525-May 00:4424-May 22:05
31324-May 23:2224-May 23:4524-May 21:22
31423-May 21:5323-May 22:0523-May 19:53
IC Live 4004xxxx
Cell Formulas
RangeFormula
D303:D314D303=IF(B303>0,B303-(1/12),"")
Cells with Data Validation
CellAllowCriteria
D303:D314Text length=0
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

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