SQL SERVER 2008 - Sql query for specific date range and date time

I need to query all values between specified date range and time range. For example, I want to query all the values from 5:00Pm on 16-Sep-2010 to 9:00AM 21-Sep-2010. Any ideas how the query should be.

Thanx in advance.

This question and answers originated from www.stackoverflow.com
Question by (9/21/2010 1:49:34 PM)

Answer

Infact this worked for me

 SELECT * 
 FROM myTable
 WHERE CAST(ReadDate AS DATETIME) + ReadTime BETWEEN '2010-09-16 5:00PM' AND '2010-09-21 9:00AM'
Answer by

Find More Answers
Related Topics  sql-server-2008
Related Questions
  • SQL Date Range Query

    I have a SQL2005 database with a table that has a field that is in datetime format and hold the date and time that a record was added. A typical entry looks like 10/03/2011 13:35:15 How do I quer…
  • Date Range SQL Query

    Schedule_ID---Card No----FromDate----ToDate 4-------------1000058----01-Aug-10---31-Aug-10 5-------------1000058----01-Sep-10---30-Sep-10 6-------------1000058----06-Oct-10---26-Oct-10 7-----------…
  • Date and time Query - problem

    I try to run this query: select * from WorkTbl where ((Tdate >= '20100414' AND Ttime >= '06:00') and (Tdate <= '20100415' AND Ttime <= '06:00')) I have this date: 14/04/2010 and t…
  • SQL server 2005 - query aribitrary time interval in date range

    I have a DateTime column. I want to extract all records, lets say, from 8:30 to 16:15 within a certain date range. My problem is that I need to compare hour and minute as a single time value. I can …
  • Date & time query question (SQL Server 2008)

    I have table that contain date and time field. id|date|time ========= 1|01/01/2001|10:45 2|01/02/2002|11:45 3|01/03/2003|12:45 4|01/04/2004|12:55 I need to know the difference between the MAX…
  • Query with date range and specific times range?

    I have this query for a DB2 DB where I need to pull data between dates and specific times. I came up with the query below and it is working but is not getting the data for the day in between 2011051…
  • SQL Query for Date Range, multiple start/end times

    A table exists in Microsoft SQL Server with record ID, Start Date, End Date and Quantity. The idea is that for each record, the quantity/total days in range = daily quantity. Given that a tabl…
  • Select a random date within specific range

    How can I select a random date within a specific inclusive range, let's say '1950-01-01' and '1999-12-31' with SQL Server?
  • sql query date time

    i have a datestamp field in my table structure. using sql, i want to find any user who registered in yesterdays date using these time range. eg: 2010-02-06 14:00:00 2010-02-07 10:00:00 i will…
  • Join query on Date Range

    HI I have following tables ========================= Periods ========================= PeriodID StartDate EndDate 1 01-01-11 07-01-11 2 08-01-11 15-01-11 and so on for whole year …