SQL query to select data between two dates and times

0 votes

My table contains a [time] field that is a DateTime variable with the type 2014-04-08 23:55:00.000. I want to choose every record that occurred between two particular hours and dates.

Like this:

SELECT * FROM  [table] 
WHERE time >=2014-04-08 23:53:00.000 AND time <= 2014-04-08 23:58:00.000

I wrote a SQL query:

SELECT * FROM [table]
WHERE time BETWEEN #4/19/2014 12:00:00 AM# and #4/19/2014 12:30:00 AM#

But it's giving me this error:

Incorrect syntax near '12'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Can someone help me solve this?

Aug 25, 2022 in Database by Kithuzzz
• 38,000 points
2,276 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Database

0 votes
0 answers

Select data from date range between two dates

I have a database called Product Sales ...READ MORE

Sep 2, 2022 in Database by Kithuzzz
• 38,000 points
873 views
0 votes
1 answer

Hours and minutes difference between two times in Excel

Using the TEXT function in Excel is ...READ MORE

answered Mar 25, 2022 in Database by gaurav
• 23,260 points
1,175 views
0 votes
0 answers

Export SQL query data to Excel

My query returns a huge amount of ...READ MORE

Aug 18, 2022 in Database by Kithuzzz
• 38,000 points
565 views
+1 vote
0 answers

SQL: Two select statements in one query

I want to return the newly created ...READ MORE

Aug 20, 2022 in Database by Kithuzzz
• 38,000 points
6,013 views
0 votes
0 answers

SQL how to compare two tables for same data content?

I have two tables, TableA and TableB, ...READ MORE

Aug 25, 2022 in Database by Kithuzzz
• 38,000 points
848 views
0 votes
0 answers

How to create a table from select query result in SQL Server 2008

I tried to build a table from ...READ MORE

Sep 2, 2022 in Database by Kithuzzz
• 38,000 points
860 views
0 votes
1 answer

Calculate Time Intersection to Correlate Sequences of Independent Events

I think this solution requires a CROSS JOIN implementation. ...READ MORE

answered Oct 26, 2018 in Power BI by Upasana
• 8,620 points
799 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,070 points
827 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,070 points
552 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,020 points
1,064 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP