Fix integer overflow problem in the date computation.

Also, add a backoff + retry strategy for queries.
Merge pull request #327 from gdusbabek/migration_fix_date

Fix integer overflow problem in the date computation.