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

  • Home
  • SEARCH
  • 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 9233085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:28:05+00:00 2026-06-18T06:28:05+00:00

My Question is, I have a Column of type DateTime in SQL Table and

  • 0

My Question is,

I have a Column of type DateTime in SQL Table and it contains Values Like

2013-02-01 10:00:00.000
2013-01-27 16:00:00.000
2013-02-01 14:00:00.000

How can I get results with a Query if I only mention the Date in Where Clause like:

SELECT *
FROM   tablename
WHERE  columnName = '2013-02-01'

After executing this Query I want to have This Result

2013-02-01 10:00:00.000
2013-02-01 14:00:00.000

Kindly Help me in 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-06-18T06:28:06+00:00Added an answer on June 18, 2026 at 6:28 am

    Since your data is stored with times, you need to Cast those to just Dates.

    Try this:

    SELECT  * 
    FROM tablename 
    WHERE CAST(columnName as DATE) = '2013-02-01'
    

    Depending on your SQL Server version (if it doesn’t support DATE data type), you can use this:

    SELECT  * 
    FROM tablename 
    WHERE DATEADD(dd, 0, DATEDIFF(dd, 0, columnName)) = DATEADD(dd, 0, DATEDIFF(dd, 0, '2013-02-01'))
    

    EDIT — As others have rightfully pointed out, you lose any performance gained from table indexing on that column in the above example. This should be what you’re looking for given a single input parameter (2013-01-01 in this case):

    SELECT *
    FROM tablename
    WHERE columnName >= CONVERT(datetime,'2013-01-01')
      AND columnName < DATEADD(dd, 1, CONVERT(datetime,'2013-01-01'))
    

    Good luck.

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

Sidebar

Related Questions

I have a question about MS SQL Server string-to-datetime implicit conversion. Specifically, can I
question concerning SQL Server: I have added a column with type uid to a
I have a column in my table of type datetime . I want to
We have a CallLog table in Microsoft SQL Server 2000 . The table contains
I have a table that looks like id Type: Auto inc-int Comment: the unique
I'm using Primefaces 3.3.1 and have question. I have p:commandButton inside p:column of p:dataTable.
A very basic question in excel. I have a column with valid and with
i have an question how to use an alias column at the where/having clause.
i have four tables user-question contains two columns: questionID, userID, the questions that the
I have a question about a particular query I'd like to execute against a

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.