user3461502
user3461502

Reputation: 323

Filtering Data between Specified Dates when Date is a Timestamp

I'm trying to filter data between Jan 1st, 2021 and Jan 31st, 2021 in a Hive table. The column containing the date is in timestamp format (yyyy-mm-dd hh-mm-ss). Is there a way to filter just based on year() month and date without inputting the timing? Any examples/sample code would be welcome!

Upvotes: 1

Views: 617

Answers (1)

Koushik Roy
Koushik Roy

Reputation: 7387

You can use to_date( dt_time timestamp) dt to convert to date and remove time part.

select current_timestamp() , to_date(current_timestamp() )

enter image description here

Select * from table 
Where
To_date(input_datetime ) between to_date(from_datetime) and to_date (to_datetime)

Upvotes: 1

Related Questions