Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Whats wrong with this less-than date query?

Tags:

sql

sqlite

sqlite> SELECT * FROM RawResponseTimes WHERE CreationTime <= 2011-06-14 17:17:23;
Error: near ":17": syntax error

Everything appears to be fine but it isn't happy with the hour 17, what gives?

Using SQLite.

like image 496
Chucky Avatar asked Jul 05 '11 14:07

Chucky


People also ask

How do I query less than in SQL?

Example - Less Than Operator You can use the < operator in SQL to test for an expression less than. In this example, the SELECT statement would return all rows from the products table where the product_id is less than 5. A product_id equal to 5 would not be included in the result set.

How do you write a SQL query to compare dates?

In SQL, the date value has DATE datatype which accepts date in 'yyyy-mm-dd' format. To compare two dates, we will declare two dates and compare them using the IF-ELSE statement. We can declare variables easily by using the keyword DECLARE before the variable name. By default, the local variable starts with @.

How do I check if a date is greater than today in SQL?

GETDATE() function: This function is used to return the present date and time of the database system. After comparison column contains the following string: Lesser than- If the date is less than today's date. Greater- If the date is greater than today's date.

How do you query greater than and less in SQL?

Example - Greater Than Operator You can use the > operator in SQL Server to test for an expression greater than. SELECT * FROM employees WHERE employee_id > 3000; In this example, the SELECT statement would return all rows from the employees table where the employee_id is greater than 3000.


1 Answers

Looks like you are missing 's from your date.

SELECT * FROM RawResponseTimes WHERE CreationTime <= '2011-06-14 17:17:23';

like image 181
Neil Knight Avatar answered Oct 10 '22 06:10

Neil Knight