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 in Database by Kithuzzz
• 12,240 points
10 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 in Database by Kithuzzz
• 12,240 points
10 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 in Database by gaurav
• 18,960 points
178 views
0 votes
0 answers

Export SQL query data to Excel

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

Aug 18 in Database by Kithuzzz
• 12,240 points
16 views
0 votes
0 answers

SQL: Two select statements in one query

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

Aug 20 in Database by Kithuzzz
• 12,240 points
70 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 in Database by Kithuzzz
• 12,240 points
39 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 in Database by Kithuzzz
• 12,240 points
39 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
330 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 in Database by Vaani
• 7,020 points
121 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 in Database by Vaani
• 7,020 points
45 views
0 votes
1 answer

What is a stored procedure?

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

answered Feb 4 in Database by Neha
• 8,920 points
216 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