Days to days and months

MartinCarlsson

Board Regular
Joined
Mar 8, 2012
Messages
59
Hi
I have x number of days, and I need it to make it to days and months.

Example.
x = 45

days -> 15
months -> 1

I know there is more than one way and Im looking for the best way to do it for my program.
Any suggestions?

//Martin
 
I have x number of days, and I need it to make it to days and months

I need to make the .. number of month, even if I have 1,000 days.

And if I exchange 30 for 365.2 / 12, it returns days like: 14,5666666666667

Why would you change 30 for 365.2 / 12?

You stated you wanted x to be the number of days, therefore if x is changed to 1,000 then you get 33 month 10 days.

However, this has the limitation of your assumption of 30 days per month as previously mentioned.
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you could provide a Start Date, as well as x = 45
That would provide the most precise definition months, and would account for leap years.

You could use something like

=DATEDIF(A1,A1+B1,"m") & " Month : "&DATEDIF(A1,A1+B1,"md")&" Day"

A1 = Start Date
B1 = 45


For Today's date 6/26/2012 in A1, that returns

1 Month : 15 Day
 
Last edited:
Upvote 0
Thanks!

Your code is a bit confusing.
Why do you use "=TODAY()" instead og Now()
Why do you loop?
Why do you end the loop with an if statement instead of the usual way?
Instead of
Code:
Now()
I suggest
Code:
Int(Now())
I use loop, because I want find the maximal number of mounts satisfying Your Conditions. I answer to the last Question: I end the loop this Way becase I like this Way, best regards. :)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,864
Messages
6,121,981
Members
449,058
Latest member
oculus

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