I have the following code,and I am trying to compare The date string with date time,but I can’t get it to work.This does not output any rows.
DataTable tbl3 = dii.SelectGeneric("select * from widget_messages where convert(datetime, m_date) ='" + String.Format("{0:d/M/yyyy}", DateUsed) + "'");
Both datetimes are formatted exactly the same.Any ideas?
You are converting the
m_datetodatetimebutDateUsedremains a string.You should either compare them as strings, like this
or as datetimes, like this:
EDIT: On SQL Server 2005 try this: