SQL Server Query for selecting rows with times based on a specified user-inputted timespan

terrible-coder

Is there a way to query a database to return rows containing data with a time datatype that is dependent on the user providing a time span (like for example, querying between 5:00 to 11:00 will return all rows containing times from 5:00 all the way to 11:00 and not simply exactly 5:00 and 11:00)?

Is the problem stated above possible? Or I should only rely on programatically setting the parameters in my program?

I know that this one will definitely not work with what I aim to know.

SELECT *   
FROM Consultation
WHERE (Consultation_Day = 'Monday') AND (Time_From = '5:00') OR (Time_From = '11:00')
ORDER BY Last_Name
Habib

Your condition for Time is checking for exact time of either 5:00 or 11:00 for range you can do:

(Time_From >= '5:00') AND (Time_From <= '11:00')

So your query should be:

SELECT *   
FROM Consultation
WHERE (Consultation_Day = 'Monday') AND ((Time_From >= '5:00') AND (Time_From <= '11:00'))
ORDER BY Last_Name

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

selecting random rows with normal distribution based on a column in SQL Server 2012

From Dev

selecting random rows with normal distribution based on a column in SQL Server 2012

From Dev

SQL Server - Return rows based on user role

From Dev

Selecting employee based availability Query SQL Server 2012

From Dev

sql selecting and joining rows multiple times

From Dev

Selecting N rows in SQL Server

From Dev

Selecting N rows in SQL Server

From Dev

Selecting rows using user id in Oracle SQL

From Dev

SQL - Selecting rows based on date difference

From Dev

SQL Server column was specified multiple times

From Dev

sql server - selecting top x rows by group

From Java

SQL Server query - Selecting COUNT(*) with DISTINCT

From Dev

Selecting record range dynamically in a SQL Server query

From Dev

Query rows modified in certain timespan

From Dev

how to update all rows of a specified data group in SQL server based on a condition?

From Dev

Selecting grouped rows after first two rows SQL Server

From Dev

Return inserted rows in specified order for Sql Server

From Dev

SQL Server: selecting a row multiple times by the given factor

From Dev

How do I Output into Self Specified Data like Yes or No into Self Specified Columns Based on the result of a Query SQL Server 2008

From Dev

SQL Query for selecting multiple rows but highest value for each PK

From Dev

Partition in a sql query, selecting only previous rows without the current one

From Dev

SQL Server - Count the number of times the contents of a specified field repeat in a table

From Dev

Selecting all the rows if where condition is null in SQL Server

From Dev

SQL for selecting rows in DB

From Dev

SQL selecting rows

From Dev

Rows to Column conversion Sql query SQL SERVER

From Dev

How to take top 1 rows for based on Datetime variation in SQL Server using Inner Join query?

From Dev

SQL Query to find rows based on descriptions

From Dev

SQL query to fetch rows based on a column

Related Related

  1. 1

    selecting random rows with normal distribution based on a column in SQL Server 2012

  2. 2

    selecting random rows with normal distribution based on a column in SQL Server 2012

  3. 3

    SQL Server - Return rows based on user role

  4. 4

    Selecting employee based availability Query SQL Server 2012

  5. 5

    sql selecting and joining rows multiple times

  6. 6

    Selecting N rows in SQL Server

  7. 7

    Selecting N rows in SQL Server

  8. 8

    Selecting rows using user id in Oracle SQL

  9. 9

    SQL - Selecting rows based on date difference

  10. 10

    SQL Server column was specified multiple times

  11. 11

    sql server - selecting top x rows by group

  12. 12

    SQL Server query - Selecting COUNT(*) with DISTINCT

  13. 13

    Selecting record range dynamically in a SQL Server query

  14. 14

    Query rows modified in certain timespan

  15. 15

    how to update all rows of a specified data group in SQL server based on a condition?

  16. 16

    Selecting grouped rows after first two rows SQL Server

  17. 17

    Return inserted rows in specified order for Sql Server

  18. 18

    SQL Server: selecting a row multiple times by the given factor

  19. 19

    How do I Output into Self Specified Data like Yes or No into Self Specified Columns Based on the result of a Query SQL Server 2008

  20. 20

    SQL Query for selecting multiple rows but highest value for each PK

  21. 21

    Partition in a sql query, selecting only previous rows without the current one

  22. 22

    SQL Server - Count the number of times the contents of a specified field repeat in a table

  23. 23

    Selecting all the rows if where condition is null in SQL Server

  24. 24

    SQL for selecting rows in DB

  25. 25

    SQL selecting rows

  26. 26

    Rows to Column conversion Sql query SQL SERVER

  27. 27

    How to take top 1 rows for based on Datetime variation in SQL Server using Inner Join query?

  28. 28

    SQL Query to find rows based on descriptions

  29. 29

    SQL query to fetch rows based on a column

HotTag

Archive