View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Sean Timmons Sean Timmons is offline
external usenet poster
 
Posts: 1,696
Default Difference between dates returning full months and remaining days

=IF(DAY(N13)<DAY(M13),(YEAR(N13)-YEAR(M13))*12+MONTH(N13)-MONTH(M13)-1,(YEAR(N13)-YEAR(M13))*12+MONTH(N13)-MONTH(M13))

seems to get numbero f months

and

=IF(DAY(N13)-DAY(M13)0,DAY(N13)-DAY(M13),EOMONTH(M13,0)-M13+DAY(N13))

seems to get # of days.

"kvan" wrote:

I'm trying to calculate difference between dates, but with a twist- I need to
return the number of full months between beginning and end dates, then, in
the next cell over, the remaining days. Here's where I am so far
(M=BeginDate, N=EndDate) for Months:
=IF(OR(M13="",N13=""),"",IF((DAY(M13)=1),(YEAR(N13 )-YEAR(M13))*12+MONTH(N13)-MONTH(M13)+1,(YEAR(N13)-YEAR(M13))*12+MONTH(N13)-MONTH(M13)))

Days:
=IF(OR(M13="",DAY(M13)=1),"",IF(N13="","",DAY((EOM ONTH(M13,0))-DAY(M13)+1)))

This is returning properly only if EndDate is the last day of a month. I
need it to work regardless of when the month the EndDate falls. Any
suggestions? Any help is much appreciated!