From: Microsoft on
Excel 2007

1 have a

start date: 01/01/2009
finish date: 23/06/2010

I want to calculate the length of service between the two dates to the
nearest month, eg (dates abaove) and return a string like so

result = 1 year 6 months

how can I do this?

Thanks

A


From: Steve Dunn on
Assuming that A2 is always a later date than A1:

=YEAR(A2)-YEAR(A1)-
(MONTH(A2)<MONTH(A1))&" year(s) "&
MONTH(A2)-MONTH(A1)+
12*(MONTH(A2)<MONTH(A1))&" month(s)"


HTH
Steve D.


"Microsoft" <nospam(a)nowhere.com> wrote in message
news:uBLmBrX$KHA.1448(a)TK2MSFTNGP06.phx.gbl...
> Excel 2007
>
> 1 have a
>
> start date: 01/01/2009
> finish date: 23/06/2010
>
> I want to calculate the length of service between the two dates to the
> nearest month, eg (dates abaove) and return a string like so
>
> result = 1 year 6 months
>
> how can I do this?
>
> Thanks
>
> A
>

From: Ron Rosenfeld on
On Thu, 27 May 2010 09:58:17 +0100, "Microsoft" <nospam(a)nowhere.com> wrote:

>Excel 2007
>
>1 have a
>
>start date: 01/01/2009
>finish date: 23/06/2010
>
>I want to calculate the length of service between the two dates to the
>nearest month, eg (dates abaove) and return a string like so
>
>result = 1 year 6 months
>
>how can I do this?
>
>Thanks
>
>A
>

You can probably use the DATEDIF function (undocumented except in Excel 2000
and also on Chip Pearson's web site http://www.cpearson.com/excel/datedif.aspx
)

Formulas like:

=DATEDIF(StartDate,FinishDate,"y")
=DATEDIF(StartDate,FinishDate,"ym")

However, I don't know what you mean by "to the nearest month".

Do you want to first "round" startdate and finishdate to the closest month,
then determine the difference?

Do you want to add one month if the difference is some predetermined number of
days? If so, what is that number?

etc.
--ron
From: Ms-Exl-Learner on
Assume that your Start date is in A1 cell and the end date is in A2 cell.

Copy and paste the below formula in A3 cell.

=IF(OR(A1="",A2=""),"",DATEDIF(DATE(YEAR(A1),MONTH(A1),DAY(A1)),DATE(YEAR(A2),MONTH(A2)+1,DAY(A2)),"Y")&"
YEAR
"&DATEDIF(DATE(YEAR(A1),MONTH(A1),DAY(A1)),DATE(YEAR(A2),MONTH(A2)+1,DAY(A2)),"YM")&" MONTH")

Remember to Click Yes, if this post helps!

--------------------
(Ms-Exl-Learner)
--------------------


"Microsoft" wrote:

> Excel 2007
>
> 1 have a
>
> start date: 01/01/2009
> finish date: 23/06/2010
>
> I want to calculate the length of service between the two dates to the
> nearest month, eg (dates abaove) and return a string like so
>
> result = 1 year 6 months
>
> how can I do this?
>
> Thanks
>
> A
>
>
> .
>
From: Mike H on
Hi

This assumes dates in A1 and A2 with A1 being the earlier date.

Datedif for those dates would normally return 1 year and 5 months using this
formula

=DATEDIF(A1,A2,"y")&" Years "&DATEDIF(A1,A2,"ym")&" Months"

To get it to round to the nearest month try

=DATEDIF(A1,A2,"y") & " years, "
&DATEDIF(A1,A2,"ym")+IF(DAY(A2)>DAY(DATE(YEAR(A2),MONTH(A2)+1,1)-1)/2,1,0) &
" months"

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Microsoft" wrote:

> Excel 2007
>
> 1 have a
>
> start date: 01/01/2009
> finish date: 23/06/2010
>
> I want to calculate the length of service between the two dates to the
> nearest month, eg (dates abaove) and return a string like so
>
> result = 1 year 6 months
>
> how can I do this?
>
> Thanks
>
> A
>
>
> .
>