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,289 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
877 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,183 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
568 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,026 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
852 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
864 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
802 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
830 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
555 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,068 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