#1   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Date Math

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


  #2   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 193
Default Date Math

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 5,651
Default Date Math

On Thu, 27 May 2010 09:58:17 +0100, "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


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
  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
external usenet poster
 
Posts: 506
Default Date Math

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(YE AR(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


.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
external usenet poster
 
Posts: 11,501
Default Date Math

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


.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2000 and date math rasinc Excel Discussion (Misc queries) 4 July 16th 09 05:01 AM
Date Math metaltecks Excel Discussion (Misc queries) 4 July 31st 06 02:11 PM
math Bill Excel Discussion (Misc queries) 3 August 11th 05 11:21 PM
Date Math Problem Dkline Excel Worksheet Functions 4 March 4th 05 04:11 PM
In Excel, I need a date math formula... Lisa Excel Discussion (Misc queries) 2 December 3rd 04 12:13 AM


All times are GMT +1. The time now is 08:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"