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 8044935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:23:22+00:00 2026-06-05T05:23:22+00:00

From my code, I call an SP using: using (var cmd = new SqlCommand(sp_getnotes))

  • 0

From my code, I call an SP using:

using (var cmd = new SqlCommand("sp_getnotes"))
{
  cmd.Parameters.Add("@ndate", SqlDbType.SmallDateTime).Value
                  = Convert.ToDateTime(txtChosenDate.Text);
  cmd.CommandType = commandType;
  cmd.Connection  = conn;

  var dSet = new DataSet();
  using (var adapter = new SqlDataAdapter { SelectCommand = cmd })
  {
    adapter.Fill(dSet, "ntable");
  }
}

The Stored Procedure itself runs a simple query:

SELECT * FROM tblNotes WHERE DateAdded = @ndate

The problem is no records are returned! DateAdded is a smalldatetime column.

When I change the query to the following, it works:

SELECT * FROM tblNotes WHERE CONVERT(DATETIME, FLOOR(CONVERT(FLOAT, DateAdded))) = @ndate

Why is this happening? This change affects the entire application and I’d like to find the root cause before getting into changing every single query… The only changes we made are to use parameterized queries and upgrade from SQL Server 2005 to 2008.

TIA.

  • 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-06-05T05:23:24+00:00Added an answer on June 5, 2026 at 5:23 am

    smalldatetime has a time portion which needs to match as well.

    Use this:

    SELECT  *
    FROM    tblNotes
    WHERE   dateAdded >= CAST(@ndate AS DATE)
            AND dateAdded < DATEADD(day, 1, CAST(@ndate AS DATE))
    

    SQL Server 2008 and above also let you use this:

    SELECT  *
    FROM    tblNotes
    WHERE   CAST(dateAdded AS DATE) = CAST(@ndate AS DATE)
    

    efficiently, with the transformation to a range performed by the optimizer.

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

Sidebar

Related Questions

Need help with deleting call log from multi numbers, using the following code i
From this code I can call bmwCars.CopyToDataTable() as I expected. var bmwCars = from
I need to invoke a call from code how can i do it ?
(Yes I know I can call Java code from Scala; but that is pointless;
I want to call my facebook send dialog function from code behind : The
I trying to write a simple function to call unmanaged code from managed code.
I am wondering if there is some way to call C++ code from Common
I need to call from my code for some other program . And I
Below is my code from my activity. I call setKey() to set the key,
I'd like to call a Clojure function from Java code. This question hasn't been

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.