I have this DateTime property in a DTO
public DateTime Dob { get; set; }
and in my code I m running a for loop to match data and manipulate them as well,
for (int i = 0; i < PatientInfo.Count; i++) { PatientInfo[i].Dob = DateTime.ParseExact(PatientInfo[i].Dob.ToString("MM/dd/YYYY"), "MM/dd/YYYY", DateTimeFormatInfo.InvariantInfo); PatientInfo[i].PartnerData = PartnerInfo.Where(a => a.FileId == PartnerInfo[i].FileId).ToList(); }
I m trying to convert the iso date in Dob ("1984-04-26T00:00:00") to just a date as MM/dd/YYYY but the code above fails, keeps returning the same value. I tried also parse and TryParseExact but they failed too
what am doing wrong here?