How to round up/down days in to month

Tyn

New Member
Joined
Aug 16, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have a task that requires calculating the working periods of employees up to date.
I use =DATEDIF(C3;TODAY();"y")&" year"&DATEDIF(C3;TODAY();"ym")&" month"&DATEDIF(C3;TODAY();"md")&" day" and the result is something like "15 years 2 months XX days"
What I want to achieve is rounding up the days, returning the result to something like "15 years 3 months" if the XX is bigger than 15, and "15 years 2 months" if otherwise.
How do I do this? Thanks.
I did think about rounding the initial dates first, then use the =DATEIF... later, but thought it might not as accurate.
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this:

=DATEDIF(C3;TODAY();"y")&" years"&DATEDIF(C3;TODAY()-15;"ym")+1&" months"
 
Upvote 0
Hello, thanks alot for the formular, looks like it works but there's a problem, when the normal result is '16 years 11 month 25 days', this formular will result in '16 years 0 month'
How do i fix this?
Also, can you explain what's the bold parts mean in this? Why is it '-15' and '+1' and not the other way around?
Sorry for lots of questions.
 
Upvote 0
After thinking for a bit I did this: the result looks ok. I dont know if you have better solution. Tried this with Sep 1st 2005 - today
=if(DATEDIF(G2;TODAY()+15;"ym")=0; DATEDIF(G2;TODAY();"y")+1&" years "; DATEDIF(G2;TODAY();"y")&" years "&DATEDIF(G2;TODAY()-15;"ym")+1&" months")
 
Upvote 0
After thinking for a bit I did this: the result looks ok. I dont know if you have better solution. Tried this with Sep 1st 2005 - today
=if(DATEDIF(G2;TODAY()+15;"ym")=0; DATEDIF(G2;TODAY();"y")+1&" years "; DATEDIF(G2;TODAY();"y")&" years "&DATEDIF(G2;TODAY()-15;"ym")+1&" months")
Try to test with 2 Aug 2005 - TODAY
 
Upvote 0
With start date is in G2, result is in H2.
Try this:
Code:
=SUBSTITUTE(DATEDIF(G2,end,"y") & " years " & DATEDIF(G2,end,"ym") & " months "," 0 months","")
with "end" is a Name
Stay in cell H2, hit F3 button to create a user define name:
Name: end
Refer to:
Code:
=EDATE(Sheet1!G2,DATEDIF(Sheet1!G2,TODAY(),"y")*12+DATEDIF(Sheet1!G2,TODAY(),"ym")+(DATEDIF(Sheet1!G2,TODAY(),"md")>15))

Or, without name (longer formula)
I2:
Code:
=SUBSTITUTE(DATEDIF(G2,EDATE(G2,DATEDIF(G2,TODAY(),"y")*12+DATEDIF(G2,TODAY(),"ym")+(DATEDIF(G2,TODAY(),"md")>15)),"y") & " years " &
 DATEDIF(G2,EDATE(G2,DATEDIF(G2,TODAY(),"y")*12+DATEDIF(G2,TODAY(),"ym")+(DATEDIF(G2,TODAY(),"md")>15)),"ym") & " months "," 0 months","")
Book1
GHI
201/08/200517 years 1 months 17 years 1 months
Sheet1
Cell Formulas
RangeFormula
H2H2=SUBSTITUTE(DATEDIF(G2,end,"y") & " years " & DATEDIF(G2,end,"ym") & " months "," 0 months","")
I2I2=SUBSTITUTE(DATEDIF(G2,EDATE(G2,DATEDIF(G2,TODAY(),"y")*12+DATEDIF(G2,TODAY(),"ym")+(DATEDIF(G2,TODAY(),"md")>15)),"y") & " years " & DATEDIF(G2,EDATE(G2,DATEDIF(G2,TODAY(),"y")*12+DATEDIF(G2,TODAY(),"ym")+(DATEDIF(G2,TODAY(),"md")>15)),"ym") & " months "," 0 months","")
 
Upvote 0

Forum statistics

Threads
1,223,933
Messages
6,175,475
Members
452,646
Latest member
tudou

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