• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Number of days in a year

sreejithbgs

New Member
Hi i want to get the number of days in a year, of a common year as well as a leap year.

I made an equation to get it from a cell with date;

=if(mid(year(04/01/2012)/4,4,3)=0,366,365)

But 'if()' is not taking the result of 'mid()' as '0' when it is a leap year. It is giving '365' always.Please help me.

Thanks
 
If the date is in A1, formula could be:

=DATE(YEAR(A1),12,31)-DATE(YEAR(A1),1,0)
 
Hi,


Another alternative is the DATEDIF function


=DATEDIF(DATE(YEAR(A1),1,1),DATE(YEAR(A1),12,31),"d")


@Luke,


Yours should be =DATE(YEAR(A1),12,31)-DATE(YEAR(A1),1,1)
 
@Oldcghippy


Lukes formula
Code:
=DATE(YEAR(A1),12,31)-DATE(YEAR(A1),1,0)
is correct


You need to add 1 to your formula
 
@Hui..,


Thanks for correcting me


@Luke,


Apologies my friend, that's me not reading the question properly and having a senior moment :)
 
No worries Oldchippy. I actually did have what you wrote at first, but then realized I needed to account for 1 more day. =)
 
Back
Top