D
D
Denis Lvov2020-10-23 17:10:42
SQL
Denis Lvov, 2020-10-23 17:10:42

How to filter by date in timestamp field?

I have a table in hive: table (id, date)
date in format 'yyyy-MM-dd HH:mm:ss'
how to filter for example:
WHERE date = '2020-01-01'

does not return anything
explicit conversion operator required date please help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2020-10-23
@dwenlvov

For MySQL you can do this:

WHERE `date` BETWEEN :date AND :date + INTERVAL 1 DAY
It may be different in other dialects.

R
res2001, 2020-10-23
@res2001

WHERE date >= '2020-01-01 00:00:00' and date <= '2020-01-01 23:59:59'

Well, or select the date from the timestamp and compare only with the date.
It is better to present the date in a more universal format: 'YYYYMMDD HH:MM:SS'
And write which server you are using.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question