Display Difference between Two dates Depending on Length of Difference

jski21

Board Regular
Joined
Jan 2, 2019
Messages
133
Office Version
  1. 2016
Platform
  1. Windows
Good Day Mr. Excel Team,

Is there a way to show the difference between two dates with the result specific to the time frame? Example: if the length is less than 6 months, the result will be in "000 days". If the length of time is greater than 6 months but less than 1 year, the result will display as "0.0 months", and if the length of difference is one year or more, the result will display "0.0 years".

Looking for this in one formula perhaps? Possible?

Thanks,

jski
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi jski,

you may want to use the following formula.

My spreadsheet layout is given below.


1612996699783.png


Enter the following formula in C1 and copy it down

==IF((DATEDIF(A1,B1,"m"))<6,DATEDIF(A1,B1,"d"),IF((DATEDIF(A1,B1,"m"))>=12,DATEDIF(A1,B1,"y"),DATEDIF(A1,B1,"m")))


Kind regards

Saba
 
Upvote 0
Hi jski,

you may want to use the following formula.

My spreadsheet layout is given below.


View attachment 31772

Enter the following formula in C1 and copy it down

==IF((DATEDIF(A1,B1,"m"))<6,DATEDIF(A1,B1,"d"),IF((DATEDIF(A1,B1,"m"))>=12,DATEDIF(A1,B1,"y"),DATEDIF(A1,B1,"m")))


Kind regards

Saba
I see...thank you. I could add TEXT Formulas if I wanted to have it say "180 days", or "6 months", or "1 year", yes?
 
Upvote 0
Yes you can.

or you can use the following updated formula.

=IF((DATEDIF(A1,B1,"m"))<6,IF(DATEDIF(A1,B1,"d")=1, DATEDIF(A1,B1,"d")&" day", DATEDIF(A1,B1,"d")&" days"),IF((DATEDIF(A1,B1,"m"))>=12,IF(DATEDIF(A1,B1,"y")=1,DATEDIF(A1,B1,"y")& " year",DATEDIF(A1,B1,"y")& " years"),DATEDIF(A1,B1,"m")&" months"))

The output of the formula is shown below.

1613001542085.png



Kind regards

Saba
 
Upvote 0
Yes you can.

or you can use the following updated formula.

=IF((DATEDIF(A1,B1,"m"))<6,IF(DATEDIF(A1,B1,"d")=1, DATEDIF(A1,B1,"d")&" day", DATEDIF(A1,B1,"d")&" days"),IF((DATEDIF(A1,B1,"m"))>=12,IF(DATEDIF(A1,B1,"y")=1,DATEDIF(A1,B1,"y")& " year",DATEDIF(A1,B1,"y")& " years"),DATEDIF(A1,B1,"m")&" months"))

The output of the formula is shown below.

View attachment 31774


Kind regards

Saba
Got it Saba. Very instructive. Thanks for your time!
 
Upvote 0

Forum statistics

Threads
1,215,218
Messages
6,123,676
Members
449,116
Latest member
HypnoFant

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top