Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 959811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:05:02+00:00 2026-05-16T01:05:02+00:00

I am trying to match a date from a column in excel sheet whose

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T01:05:02+00:00Added an answer on May 16, 2026 at 1:05 am

    Since you’re using the JET db provider (I’m assuming here), which means your connection string looks something like:

    string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\SOTest3.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
    

    Your dates need to be surrounded with ‘#’ signs (excluding single quotes). That should work.

    Here’s an example that works for me:

    static void Main(string[] args)
    {
        string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\SOTest3.xls;Extended Properties=""Excel 8.0;HDR=YES;""";
        DbProviderFactory factory =
          DbProviderFactories.GetFactory("System.Data.OleDb");
    
        using (DbConnection connection = factory.CreateConnection())
        {
            connection.ConnectionString = connectionString;
            using (DbCommand command = connection.CreateCommand())
            {
                connection.Open();  //open the connection 
                DateTime dtNew = Convert.ToDateTime("7/21/2010");
                DbDataAdapter da = factory.CreateDataAdapter();
                da.SelectCommand = command;
                da.SelectCommand.Connection = connection;
                da.SelectCommand.CommandText = "SELECT * FROM [Sheet1$] WHERE [Hand Off Date] = #" + dtNew.ToString("yyyy-MM-dd") + "#";
                DataTable dtDate = new DataTable();
                da.Fill(dtDate);
                Console.WriteLine(dtDate.Rows.Count);
                Console.ReadLine();                    
            }
        }
    }
    

    Hope this helps!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to match a date in PHP using preg_match, split it and
I am trying to match & group ( any phrase )##date##( any phrase ),
I'm trying to match the '12345' from a url in this form: http://domain.com/folder/title_of_this_12345 So
I am trying to match words driven from a database in a string input
I am trying to match for country or Country using lower-case function in XPath.
I'm trying to format a date from a RSS feed: Mon, 27 Feb 2012
I'm trying to run a pull request from git using PHP's exec on windows
I am trying to extract a date from a string variable and was hoping
I have following string. DATE: 12242010Key Type: Nod32 Anti-Vir (30d trial) Key: a5B2s-sH12B-hgtY3-io87N-srg98-KLMNO I
I'm trying to make a date regex that allows years from 1900 to 2099,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.