Athena greater than condition in date column Athena greater than condition in date column sql sql

Athena greater than condition in date column


You need to use a cast to format the date correctly before making this comparison. Try the following:

SELECT observation_date, COUNT(*) AS countFROM db.table_nameWHERE observation_date > CAST('2017-12-31' AS DATE)GROUP BY observation_date

Check it out in Fiddler: SQL Fidle

UPDATE 17/07/2019

In order to reflect comments

SELECT observation_date, COUNT(*) AS countFROM db.table_nameWHERE observation_date > DATE('2017-12-31')GROUP BY observation_date


You can also use the date function which is a convenient alias for CAST(x AS date):

SELECT * FROM date_dataWHERE trading_date >= DATE('2018-07-06');


select * from my_schema.my_table_name where date_column = cast('2017-03-29' as DATE) limit 5