SQL 2008 Query

Posted on 2011-10-27
Last Modified: 2012-05-12
I have a table called plant, a column called Date Rec and info as follows:

4/10/2010 0:00
4/20/2010 0:00
6/16/2010 0:00
6/17/2010 0:00
9/14/2010 0:00
9/14/2010 0:00
9/15/2010 0:00
9/17/2010 0:00

I need to select all data that is later  than 7-31-2010 and and earlier than 7-31-2011

Can anyone help me with a basic query on this?


Question by:HDM
    LVL 41

    Expert Comment

    like this

    select * from plant where [Date Rec] > '2010-07-31' and [Date Rec] < '2011-07-31'
    LVL 22

    Assisted Solution


    If the data it's just date (that is, timeportion is always 0:00) try

    select * from yourtable where yourdate between '8-1-2010' between '7-30-2011'

    LVL 41

    Accepted Solution

    or if there's a time portion involved

    select * from plant where [Date Rec] >= '2010-08-01' and [Date Rec] < '2011-07-31'
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now