# Months in 2 dates

#### zwaz

##### New Member
Hi

Is there a way to identify the number od days between 2 dates and the month

Example

01/01/08 - 15/03/08

Answer = Jan = 31 days, Feb - 29 days, March = 15 days

Any help would be greatly appreciated

### Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

#### xld

##### Banned
This will give you a value for each of the 12 months if entered in a cell and copied down 12 cells in a column

=SUMPRODUCT(--(MONTH(ROW(INDIRECT(\$A\$1&":"&\$B\$1)))=ROW(A1)))

If you want it in a row, change ROW to COLUMN.

#### northwolves

##### Well-known Member
Try the following codes:
Code:
``````Sub macro1()
MsgBox getall(#1/1/2008#, #9/15/2008#)
End Sub
Function getall(ByVal d1 As Date, ByVal d2 As Date) As String
Dim s() As String, i As Long
ReDim s(Month(d1) To Month(d2))
For i = LBound(s) To UBound(s)
s(i) = Format(DateSerial(Year(d1), i + 1, 0), "mmm=d") & " days"
Next
s(LBound(s)) = Format(d1, "mmm=") & DateSerial(Year(d1), Month(d1) + 1, 0) - d1 & " days"
s(UBound(s)) = Format(d2, "mmm=d") & " days"
getall = Join(s, ",")
End Function``````

Regards
Northwolves

#### barry houdini

##### MrExcel MVP
If your start date is in A2 and end date in B2 then you could list the 1st of each month in D1 across, e.g. D1 has 1-Jan-2008, E1 has 1-Feb-2008, F1 has 1-March-2008, extend as far as necessary [format these dates as mmm-yy if you wish]

Then in D2 copied across

=MAX(0,MIN(\$B2,D\$1+32-DAY(D\$1+32))-MAX(\$A2,D\$1)+1)

Replies
13
Views
301
Replies
5
Views
83
Replies
7
Views
69
Replies
2
Views
200
Replies
4
Views
331

1,191,671
Messages
5,987,956
Members
440,121
Latest member
eravella

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