# Keeping monthly billing dates from drifting

If a subscription starts on January 31, 2026, a one-month shift gives you February 28. Shift again from there and the next bill lands on March 28. Keep the original date and shift by the number of months since signup.

```elixir
anchor = ~D[2026-01-31]
february = Date.shift(anchor, month: 1)

Date.shift(february, month: 1) #=> ~D[2026-03-28]
Date.shift(anchor, month: 2)   #=> ~D[2026-03-31]
```

`Date.shift/2` clamps the day to the last valid day of the target month. Using the original date each time keeps the 31st when the month has one.

https://hexdocs.pm/elixir/Date.html#shift/2


---

Created by: almirsarajcic
Date: November 09, 2026
URL: https://elixirdrops.net/d/QTfgUyX6
