Cast varchar date fields to int when selecting from the database (see #5503)