Ensure that undefined datetimes are always written as UNDEFINED_DATE to
the db