I am trying to match a date from a column in excel sheet whose column type is DateTime.
using following query
DateTime dtNew = Convert.ToDateTime("7/16/2010");
OleDbDataAdapter da = new OleDbDataAdapter("Select * FROM [" + SheetName + "$] where [Hand off date] = '" + dtNew + "'", conn);
I am getting
Datatype mismatch in criterion expression’.
please help on this.
Since you’re using the JET db provider (I’m assuming here), which means your connection string looks something like:
Your dates need to be surrounded with ‘#’ signs (excluding single quotes). That should work.
Here’s an example that works for me:
Hope this helps!!