# Dates in IF Function ?

#### Neveraliein

##### New Member
This is really getting to me because I'm sure it's simple.
In Row 1 we have months mmm
In Column A there are various dates dd/mmm/yy
We, ultimately, want columns to total so we know occurences per month. IF A2 = date in jan it will return value of 1 in B2.
We tried (in B2) =IF(AND(A2>31/12/2007,A2<30/1/2008),1,0)

Bet someone has asked this before, but I haven't found anything in previous posts.

Any assistance would be appreciated
Thanks

### Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

#### Gerald Higgins

##### Well-known Member
Hi N. . . and welcome to the board.

Perhaps try
Code:
``=if(and(a2>date(2007,12,31),a2< date(2008,1,30)),1,0)<DATE(2008,1,30)),1,0)< p>``

#### barry houdini

##### MrExcel MVP
Rather than testing each date separately you could use one formula that will count how many dates are in each month, e.g.

=SUMPRODUCT(--(TEXT(A2:A100,"mmm-yy")="jan-08"))

will count how many dates in A2:A100 fall in January 2008

#### Neveraliein

##### New Member
Fantastic help, thanks. Both solutions are really useful

Replies
10
Views
82
Replies
1
Views
57
Replies
1
Views
238
Replies
4
Views
126
Replies
1
Views
419

1,191,521
Messages
5,987,073
Members
440,074
Latest member
Emmanuelian

### 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.

### Which adblocker are you using?

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

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