Convert String to Nullable DateTime [duplicate]

You can try this:-

 DateTime? dt = string.IsNullOrEmpty(date) ? (DateTime?)null : DateTime.Parse(date);

Leave a Comment