added flag to cast invalid dates to null