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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:57:31+00:00 2026-06-15T23:57:31+00:00

I have a column in my table for dates (DateTime) and I am trying

  • 0

I have a column in my table for dates (DateTime) and I am trying to create a WHERE clause that says, WHERE dates BETWEEN 12-11-2012 and 12-13-2012

A sample value of dates column = 2012-05-24 00:38:40.260

I want to say WHERE dates BETWEEN MM-DD-YYYY and MM-DD-YYYY.

I tried doing

WHERE dates BETWEEN ((convert(nvarchar(10), dates,110) = '2012-12-12') AND (convert(nvarchar(10), dates,110) = '2012-12-12'))

but doesn’t seem to work. “Incorrect syntax near =”

Please help

EDIT:

Thanks for various options and description guys. Got it working with @RichardTheKiwi’s options.

  • 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-15T23:57:31+00:00Added an answer on June 15, 2026 at 11:57 pm

    If your dates column does not contain time information, you could get away with:

    WHERE dates BETWEEN '20121211' and '20121213'
    

    However, given your dates column is actually datetime, you want this

    WHERE dates >= '20121211'
      AND dates < '20121214'  -- i.e. 00:00 of the next day
    

    Another option for SQL Server 2008 onwards that retains SARGability (ability to use index for good performance) is:

    WHERE CAST(dates as date) BETWEEN '20121211' and '20121213'
    

    Note: always use ISO-8601 format YYYYMMDD with SQL Server for unambiguous date literals.

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

Sidebar

Related Questions

I have a table called actions with a DATETIME column called occurred. I'm trying
I have this table: ID(INT) DATE(DATETIME) Under the DATE column there are a lot
So if I have a table as follows with column date datetime employee varchar
I have a table that contains records with a column indicates the Date. Given
I'm trying to create a table that has a primary key (Department_ID) that auto
I have a DATETIME column in my database. I need to get the value
I have a table: create table practice_table ( traffic_date datetime , door_one integer ,
I have a table with a column dedicated solely to DATETIME values (e.g. 2010-11-12
I have a table with a DATETIME column. I would like to SELECT this
I have daily scheduled task that queries a table which includes column named AttemptDate

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.