Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I filter by date in SQL?

I’m trying to filter by date in a SQL query as follows.

select *
from table_name 
where date_col="2015-04-02"
limit 5

I’m getting an error as follows.

DatabaseError: Execution failed on sql '
select *
from table_name
where date_col="2015-04-02"
limit 5
': column "2015-04-02" does not exist
LINE 4: where date_col="2015-04-02"

Date 2015-04-02 exists in the database. What am I missing here?
I really appreciate any help you can provide.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You must use single quotes in where clause, double quotes are used in column identifier or reserved words.

select *
from table_name
where date_col = '2015-04-02'
limit 5
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading