Round Months

Boeskool

New Member
Joined
Aug 15, 2012
Messages
5
Hi All,

To track employees' service time I have 2 dates (A1=start date and B1=end date). After substracting B1-A1/365.25 the outcome could e.g. be 10 years 5 months, but could also be 10 years and 7 months (cell is formatted on number). What I'd like to do is, have a formula round down months <7 to, in this example, 10 full years and months >7 to 11 full years.

Thx a lot.

Boeskool
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This will round the years up or down at the six month mark.

=DATEDIF(A1,EDATE(B1,6),"y")

I wasn't sure if you intended to round at the 6 month mark (half a year) or the seven month. If you want to round at the seventh month, change the red 6 to a 7.
 
Upvote 0
Code:
=IF((A1-B1)/365.25-ROUNDDOWN((A1-B1)/365.25,0)>(7/12),ROUNDDOWN((A1-B1)/365.25,0)+1,ROUNDDOWN((A1-B1)/365.25,0))

Code:
=IF(MOD((A1-B1)/365.25,ROUNDDOWN((A1-B1)/365.25,0))>(7/12),ROUNDDOWN((A1-B1)/365.25,0)+1,ROUNDDOWN((A1-B1)/365.25,0))

Those two work for me.
 
Upvote 0
a couple of thoughts:

1. Your desired output is unlikely to be sensistive to leap years and so I wouldn't worry about the 0.25 in your expression.
2. It doesn't matter how you've formatted the 2 dates, they will still be stored as the number of days since 1 jan 1900.
3. Your expressions for rounding look a little strange: I presume you mean to round down for <7 months and to round up for >=7 months.

My suggestion would be to replace you =(B1-A1)/365.25 with =YEARFRAC( B2, B1, 3 ), which returns the fraction of the years between the two dates. If you then format that cell as having no decimal places Excel will do the rounding for you.

Hope this helps.
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

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