Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

What is the best way to calculate anniversary billing monthly with different lengths

We want to charge for storage say starting June 1st to July 1st and if the customer stays longer than July 1st we charge another amount for the next month but July has 31 says

If all months had 30 days the system would work fine

is there a calculation or formula we can use to fix this issue?

share|improve this question
    
I don't understand why this question has been tagged computer-science. (For that matter, I don't understand the question, but maybe others do...) –  Pete L. Clark Jul 27 '11 at 21:17

1 Answer 1

up vote 1 down vote accepted

How about

$$ \Delta M = 12 (Y - Y_0) + (M - M_0) + [D \ge D_0], $$

where $Y$, $M$ and $D$ are the current year, month and day numbers, $Y_0$, $M_0$ and $D_0$ are the year, month and day of the starting date, $\Delta M$ is the calculated number of months elapsed since the starting date (rounded up) and $[Q]$ is the Iverson bracket, i.e. $1$ if the condition $Q$ is true and $0$ otherwise.

In effect, $\Delta M$ is incremented by one at the start of the $D_0$-th day of each month, unless the month has less than $D_0$ days, in which case the increment happens at the start of the first day of the next month.

share|improve this answer
    
my boss says that correct for the question I asked, apparently I asked the wrong question :), We don't know when the product is coming in, and want to calculate how much potential revenue we could make if the customer plans turn over product every n days but takes it out 4 days early and we store something else for another customer in that space in the remaining 4 days –  Scott C Jul 27 '11 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.