Formula that calculates leap and regular year days

ehoward84

New Member
Joined
Feb 12, 2016
Messages
2
Is there a formula that separates leap year and regular year days between two dates? For instance, from 1/1/2011 to 5/1/2012. If you include the last day, then there are 365 regular year days and 122 leap year days. If you do not include the last day, then there are 365 regular year days and 121 leap year days. Thanks for the help in advance
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Between 1/1/2011 and 5/1/2012 there is no Feb 29. I don't understand 122 leap year days in the period. However, you can ascertain whether a year is a leap year. One way is to use the Date function. Date(year to check,2,29). If the result of that is in March, it's not a leap year.




Sheet1

*AB
11/01/2013*
21/01/2014*
31/01/2015*
41/01/2016Leap Year
51/01/2017*
61/01/2018*
71/01/2019*
81/01/2020Leap Year
91/01/2021*
101/01/2022*
111/01/2023*
121/01/2024Leap Year

<colgroup><col style="font-weight:bold; width:30px; "><col style="width:68px;"><col style="width:115px;"></colgroup><tbody>
</tbody>

Spreadsheet Formulas
CellFormula
B1=IF(MONTH(DATE(YEAR(A1),2,29))=2,"Leap Year","")

<tbody>
</tbody>

<tbody>
</tbody>


Excel tables to the web >> Excel Jeanie HTML 4
 
Upvote 0
Thanks for the reply Steve. Since 2012 is a leap year, February of that year will have 29 days. So from 1/1/2011-12/31/2011 you have 365 days. From 1/1/2012 - 5/1/2012, you have 121 days (122 days if you include 5/1/2012).

I have my spreadsheet setup to where I can calculate the number of regular year and leap year days, however I can only do it for one date range. When I have multiple date ranges on a tab, I am unable to calculate for all of them. Sorry I am terrible at explaining. If I could include my spreadsheet to the thread it may make more sense.
 
Upvote 0
I am not sure what you require. Consider the following:
a) another way to id leap years
http://www.mrexcel.com/forum/excel-...ears-leap-year-visual-basic-applications.html

b) calculate the number of days


Excel 2010
ABC
101-01-1530-06-16
2
3Days in leap year182
4Days not in leap year365
5
3a
Cell Formulas
RangeFormula
C3=SUMPRODUCT(--(MOD(YEAR(ROW(INDEX(A:A,A1):INDEX(A:A,B1))),4)=0))
C4=SUMPRODUCT(--(MOD(YEAR(ROW(INDEX(A:A,A1):INDEX(A:A,B1))),4)<>0))
 
Upvote 0
If Dave's response does not help:


The fact the we use different date formats dd/mm/yyyy and mm/dd/yyyy/ didn't help my initial understanding of the problem but I understand the difference now now. Why do you need it - maybe annual salary or other payment division by 365 or 366? The question is only curiosity. You do not need to answer as it is not necessary to know that to answer your question.

Calculating days that fall within the leap year and outside the leap year will be mildly complex (broadly):
- Identify whether the from year, the to year or a year or years between are leap year.
- break up the date ranges to before leap year, during leap year and after leap year.
- calculate the days in each component
- add them.

Excel takes all that in its stride with a normal calculation of days between dates.

Excel 2010
AB
1From6/06/2011
2To7/07/2013
3Days(inclusive)763

<tbody>
</tbody>
Sheet1

Worksheet Formulas
CellFormula
B3=B2-B1+1

<tbody>
</tbody>

<tbody>
</tbody>

However, that does not break down to easily allow separation of the components of 366 days in 2012 and 397 days in the other years. The question now becomes, how complex does your formula need to become? Will your date ranges span long periods or will the duration always be less than two years?


If you need to add further information, there are two ways to put sample data on the forum in a way we can easily copy/paste to start working with your data:
The first is the recommended way:
Read Posting Aids on Guidelines for Forum Use
Choose an add-in (I find HTML Maker easy enough to use)
Following instructions on whichever add-in you choose to install
After installation, highlight the cells you want to copy to forum
and follow instructions to get a copy for the forum.
If using HTML make, this would be right-click one of the highlighted cells,
choose formula selection options then paste on the forum.
You will see HTML code when you paste but the result will be similar to above normal calcuation of days between dates.

The other method is to save your spreadsheet (personal data removed and sensitive data replaced) into a cloud location (e.g. Dropbox or OneDrive) and paste a link.
Warning: Some members may choose not open sample sheets posted via link.
 
Upvote 0

Forum statistics

Threads
1,216,070
Messages
6,128,618
Members
449,460
Latest member
jgharbawi

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