Aug 11 2022 01:32 AM - last edited on Nov 09 2023 11:11 AM by
I have been trying to look for the number between these two months while rounding to the next month if the day passes the 15th
Aug 11 2022 01:38 AM
Calculate the difference between two dates
Use the DATEDIF function when you want to calculate the difference between two dates. First put a start date in a cell, and an end date in another. Then type a formula like one of the following.
You can download an example workbook with all of the examples in this article.
You can follow along, or create your own formulas.
Aug 11 2022 01:41 AM
Aug 11 2022 02:36 AM
@NikolinoDE The formula didn't end up working, unfortunately.
07/01/22 | 08/20/23 |
I know that because 8/31/23 is past the 15th of the month I would round it to the next month so I'm pretty much looking for the total number of months between 7/1/22 and 9/1/23. I know the total number of months is 14. What formula should I use to figure that out?
Aug 11 2022 03:33 AM
SolutionWith dates in A3 and B3:
=(12*YEAR(B3)+MONTH(B3)+(DAY(B3)>15))-(12*YEAR(A3)+MONTH(A3)+(DAY(A3)>15))
Aug 11 2022 04:31 AM
Aug 11 2022 04:38 AM
Aug 11 2022 04:42 AM
Aug 11 2022 05:02 AM
Hi Niko,
Your formula doesn't work correctly if the dates are more than a year apart, nor if the month number of the first date is larger than the month number of the second date:
Aug 11 2022 05:12 AM
Aug 11 2022 05:16 AM - edited Aug 11 2022 05:16 AM
It's because you subtract two month numbers without taking the year into account, so the result will vary from 1-12 = -11 to 12-1 = 11.
Aug 11 2022 03:33 AM
SolutionWith dates in A3 and B3:
=(12*YEAR(B3)+MONTH(B3)+(DAY(B3)>15))-(12*YEAR(A3)+MONTH(A3)+(DAY(A3)>15))