2026 is unusual for anyone who logs business miles in the US: the IRS standard mileage rate changed mid-year. Miles driven before July 1 use 72.5¢; miles on or after July 1 use 76¢. A single rate cell in a spreadsheet silently understates the second half.
Here is a small, testable version of the calculation.
from decimal import Decimal, ROUND_HALF_UP
from datetime import date
RATE_H1 = Decimal("0.725") # before 2026-07-01
RATE_H2 = Decimal("0.76") # on or after 2026-07-01
SPLIT = date(2026, 7, 1)
def cents(x):
return x.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
def mileage_deduction(trips):
h1 = sum((Decimal(str(m)) for d, m in trips if d < SPLIT), Decimal(0))
h2 = sum((Decimal(str(m)) for d, m in trips if d >= SPLIT), Decimal(0))
a, b = cents(h1 * RATE_H1), cents(h2 * RATE_H2)
return h1, h2, a, b, a + b
trips = [(date(2026, 3, 10), 6000), (date(2026, 7, 1), 5000)]
h1, h2, a, b, total = mileage_deduction(trips)
print(h1, h2, a, b, total) # 6000 5000 4350.00 3800.00 8150.00
print(cents((h1 + h2) * RATE_H1), total - cents((h1 + h2) * RATE_H1)) # 7975.00 175.00
Design choices worth copying:
-
Decimal, neverfloat.0.725has no exact binary representation;0.725 * 6000happens to print4350.0, but the next rate or mileage may not be so lucky. -
The boundary is inclusive on the new side. IRS wording is "before July 1" for the old rate and "on or after" for the new one, so
d < SPLIT/d >= SPLIT. - Round each half, then add. Rounding the sum of unrounded halves can differ by a cent; pick one order and document it.
- Keep the rates as named constants with their source, so a future change is a one-line diff with a test.
A quick test for the boundary day:
assert mileage_deduction([(date(2026, 6, 30), 1)])[4] == Decimal("0.73") # 0.725 rounds half up
assert mileage_deduction([(date(2026, 7, 1), 1)])[4] == Decimal("0.76")
If you want the spreadsheet version (each trip row picks its own rate from its date), it is free here: https://gettidycents.com/tools/mileage-log-template
How do you handle mid-year rate changes in your own tools — date ranges in a table, or versioned constants?
Top comments (0)