I need to update some user records in my database every month (specifically, give them credits that belong to their subscription), starting the day they sign up. I thought of doing it this way:
Once every day...
- Find all users that have been updated a month ago (or more, in case the process fails for a day)
- Update them
- Increase their last update day by a month
Sounds simple, but simpler than it is. The problem is that months don't always have the same number of days. For example, if somebody signs up march 31, when should he be updated? April 30, may 1? Or should I simply restrict the range of update days to the lowest common range, 28? I could of course just do it on the 1st, for everyone, though that's less ideal.
Do you have experiences to share with situations like this? I'm using MySQL 5 from Java+JPA+Hibernate. If it helps, I'm already using JodaTime for something else.