I'm reading in a date from a textbox into a C# program and comparing to a date to entries in a SQL database. I can't get them to match, despite a SQL query of the date showing there are entries for that date.
I've tried saving to a variable with .Date
to try and strip off the hh:mm:ss
, which had no results. I've attempted DateTime.ParseExact
to change the format to match the database.
if (!System.String.IsNullOrEmpty(searchDate))
{
CultureInfo culture = new CultureInfo("en-US");
DateTime completeDate = DateTime.ParseExact(searchDate, "M/d/yyyy", culture);
requests = requests.Where(x => x.CompletionDate == completeDate);
}
I expect to find a match for two records in the database when I search for 1/28/2019
. I'm getting no results. I've tried other entries and also not found any matches. No error messages are being generated.