fix error when datetime value is nil