Check nil dates before formatting date