Try it out
type 11-Dec-2005 in cell A1
in cell B1 type the formula =Year(A1), you will get 2005
in cell C1 type the formula =Month(A1), you will get 12
in cell D1 type the formula =Day(A1), you will get 11
The same way you can create a date from its components, using the Date function.
Try it out
type 2011 in cell A3
type 12 in cell B3
type 15 in cell C3
Type formula =Date(A3,B3,C3) in cell D3. You get 15/12/2011.
As an experiment change the value in B3 to 13, the formula in cell D3 changes to reflect 15 Jan 2012. Excel is smart enough to figure out that there is no 13th month and changes the year and month accordingly.
We can use this fact to calculate the number of days in any month.
Try it out
type 5-Feb-2012 in cell A5
We want to know how many days were there in Feb 2012, so type
=Date(Year(A5),Month(A5)+1,0) in cell B5. You will get 2/29/2012. Essentially what we are doing here is asking Excel to calculate 0th day of March 2012, since Excel knows there is no 0th day in March, it calculates last day of Feb instead.
Now type =DAY(B5) in cell C5, you get the number of days in Feb 2012.
Cool, isn't it?
Calculating Number Of Days In A Month
Sunday, 12 August 2012 by nkoknki |
0
comments
Dates have three parts, Year, Month and Day. Excel provides functions to break a date into its parts. Year function can take out the year part in a date, Month function can take out the month part and Day function can take out the day part.
Source : excelfromanant[dot]blogspot[dot]com
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment