A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Date Math



 
 
Thread Tools Display Modes
  #1  
Old May 27th, 2010, 09:58 AM posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
Microsoft[_18_]
external usenet poster
 
Posts: 33
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  
Old May 27th, 2010, 10:56 AM posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
Steve Dunn
external usenet poster
 
Posts: 192
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  
Old May 27th, 2010, 11:22 AM posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
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  
Old May 27th, 2010, 10:06 PM posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
Ms-Exl-Learner
external usenet poster
 
Posts: 522
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  
Old May 27th, 2010, 10:40 PM posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
Mike H
external usenet poster
 
Posts: 8,419
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


.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:46 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.