Wednesday, August 1st, 2007

How old are you?

I know.. it’s none of my business, but sometimes you wonder, don’t you, just how old you are in days? If this question consumes your waking hours, put the calculator away and crank up Excel.

Excel’s Datedif function, while not documented, calculates the difference between two dates in a number of formats; days, months or years. The syntax of the function is: =datedif(start date,end date,units to return). The units must be provided by a quoted string in the format: “y” – full years, “m” – full months, “d” – full days, “md” – full days in excess of the last full month, “ym” – full months in excess of the last full year and “yd” – full days in excess of the last full year.

So, for example, this formula determines the number of days between the dates in cells B6 and C6: =DATEDIF(B6,C6,”d”). Type your birthday and today’s day in the cells and you’ll know immediately how old you are in days..

Helen Bradley

Wednesday, February 7th, 2007

Calculating elapsed time in Excel

It’s a common enough scenario – you want to know how old you are in months or days or the number of days left in the year. There appears to be no Excel function for calculating the difference between two dates. Not so! there is a function and it’s called Datedif.

The Excel Datedif function isn’t well known because it is largely undocumented in the Excel help files. Its purpose is to calculate the difference between two dates and it can do this by measure the distance using one of these attributes: “m” for months, “d” for days, “y” for years.

So this formula calculates the difference in months between FirstDate and SecondDate:

=Datedif(FirstDate,SecondDate,”m”)

Replace “m” with “y” to get the result in years etc..

Always ensure that the first date occurs earlier than the second or you’ll get an error.

Helen Bradley