user3868051
user3868051

Reputation: 1259

Error while executing 'select convert' on hive table

I want to execute this sql query on a hive table:

select * from sampleDB.sampleTable 
  where sampleDate>=(select convert(DATE, dateadd(MONTH,-6,getdate())));

But I am getting this error: Error while compiling statement: FAILED: parse exception line 1:64 cannot recognize input near 'select' 'convert' '(' in expression specification (state=42000,code=40000)

Can someone help me understand how this can be achieved? Basically I want to filter on date say 6 months from current date.

Thanks!

Upvotes: 0

Views: 479

Answers (1)

sandeep rawat
sandeep rawat

Reputation: 4957

Hive do not supports only >= in sub query it support only below type of sub query

  1. Scalar subqueries

  2. IN subqueries

  3. EXISTS subqueries

you can achieve the same with daenter link description hereteformate

select * from sampleDB.sampleTable 
  where sampleDate>= date_format(current_date - interval '7' day,'%Y-%m-%d') ;

Upvotes: 1

Related Questions