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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:20:56+00:00 2026-06-18T16:20:56+00:00

Hello i have a SQL Table which look like this: RESERVATIONROOM: ID NAME FROMDATE

  • 0

Hello i have a SQL Table which look like this:

RESERVATIONROOM:

ID          NAME            FROMDATE                       TODATE      

5           Room1        2012-11-29 11:46:00.000           2012-11-29 12:45:00.000
6           Room1        2012-11-29 12:55:00.000           2012-11-29 14:20:00.000
7           Room1        2012-11-29 15:00:00.000           2012-11-29 16:42:00.000

I have a from and a to date and i want to select all rooms which are between those two dates.

Example:

form date: 2012-11-29 11:50:00.000
to date: 2012-11-29 13:46:00.000

The output should be like this:

RESERVATIONROOM:

ID          NAME            FROMDATE                       TODATE      

5           Room1        2012-11-29 11:46:00.000           2012-11-29 12:45:00.000
6           Room1        2012-11-29 12:55:00.000           2012-11-29 14:20:00.000

This is what i have so far:

SELECT* 
FROM RESERVATIONROOM
WHERE FROMDATE BETWEEN CONVERT(DATETIME,'2012-11-29 11:50:00.000',101) AND CONVERT(DATETIME,'2012-11-29 13:46:00.000',101)
AND TODATE < CONVERT(DATETIME,'2012-11-29 13:46:00.000',101)
ORDER BY FROMDATE ASC

My Select Statement filters to much and i cant see all the dates which are between those two dates.

Am i missing something?

Thanks in advance for your help

  • 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-18T16:20:58+00:00Added an answer on June 18, 2026 at 4:20 pm

    Sorry for convert comment, i thought it was datetime to varchar convert.
    But from your input date, you gave two date and table has two date for each room. It is actually confusing what are these from dates and to dates. From your example output, you should use or between two filter. Look here.
    Good luck.

    select * from table1
    where (convert(datetime, @from, 101) between fromdate and todate)
    or (convert(datetime, @to, 101) between fromdate and todate)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello i have a SQL Table which look like this: ID BEZEICHNUNG PREIS UPDATE_DATE
Ok, I have a string in a sql table like this hello /r/n this
I have table which has one field (Information). Information =========== Hello World 1 This
Hello SOF community: I have a table like this InvoicingActivityStartDay InvoicingActivityEndDay 27 26 27
I have two tables like this: Table Name: users emx | userid --------------- 1
I have this table built like this, which assigns a unique articleId starting with
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I have a mysql database with in it an addresses table. This is
Hello I have table name FriendsData that contains duplicate records as shown below fID
Okay hello there I have 2 tables Route table which has route ID, frequency,

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.