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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|