Home » excel » Excel Date Rounding Calculation

Excel Date Rounding Calculation

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am currently working on a report where I want to show the months between a date and the end of 2018. Current formula is this

(IF(YEAR($H4)=2018,13-MONTH($H4),12))

I want to add in another element to say if the initial date is on or before the 15th of the month it will round down if it is 16th and after it will round up the month.

I’m struggling to add that part in. thanks in advance for your help.

How to&Answers:

There is a date in H4. Currently you have something equitable to,

=IF(YEAR($H4)=2018, 13-MONTH($H4), 12)

Append this modifier to the formula,

=IF(YEAR($H4)=2018, 13-MONTH($H4)-(DAY($H4)>15), 12)

For those dates within 2018, the months to year end are one less for dates after the 15th.

Answer:

From how I’m reading your question: You want the 15th of February to return 2 (“February”), but the 16th of February to return 3 (“March”)?

The first ‘level’ of this would simply be to change MONTH($H4) to 1+MONTH($H4-15).

1+MONTH("2018-02-15"-15)1+MONTH("2018-01-31")1+12
1+MONTH("2018-02-16"-15)1+MONTH("2018-02-01")1+23

Now, there’s 2 potential issues here: First, do you want 12th January to return 0 or 12, and Second – do you want 25th December to return 1 or 13?

(From your existing formula, I am assuming that you want 13 for late-December to get “0 months remaining this year”, but that would probably mean that any date in January should be returning 1 – otherwise you get “13 months remaining this year”)

So, running the bracketed assumptions above:

MIN(MONTH($H4),1+MONTH($H4-15))

And plug it into your formula.

(IF(YEAR($H4)=2018, 13-MIN(MONTH($H4), 1+MONTH($H4-15)), 12))