excel 2010 time difference and message -


how can compare time difference between 2 dates in excel? want 1 of following messages displayed (1-2 months, 2-4 months, 4-6 month, 6-9 months or 9 months+). if time difference either 2,4,6,9 months + days should rounded up. if number of months , days within correct time bracket should display message.

here example list of dates , time difference output should say:

start date     end date    desired message 21/06/16       29/08/16    2-4 months 12/20/16       29/08/16    6-9 months 06/06/16       29/08/16    2-4 months 28/02/15       29/08/16    9 months + 

so taking first on list: 21/06/16 - 21/08/16 = 2 months. 2 months + 8 days = 29/08/16 therefore 2 - 4 months.

first of check date format.

let's a1 start date , b1 end date.

first month count between these 2 dates , keep these in c1

((year(a1)-year(b1))*12+month(a1)-month(b1))*-1 

then

=if(c1=1,"1 - 2 months",if(and(c1>=2,c1<4),"2 - 4 months",if(and(c1<6,c1>=4),"4 - 6 months",if(and(c1>=6,c1<9),"6 - 9 months",if(and(c1>9),"9 months +","not valid date"))))) 

example


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -