Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel,microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel 2000 and date math | Excel Discussion (Misc queries) | |||
Date Math | Excel Discussion (Misc queries) | |||
math | Excel Discussion (Misc queries) | |||
Date Math Problem | Excel Worksheet Functions | |||
In Excel, I need a date math formula... | Excel Discussion (Misc queries) |