Error in MySQL to HiveQL Conversion including DATE_SUB and INTERVAL

Viewed 84

I am trying to convert the query written in MySQL to HiveQL The part of query giving me error is :

 WHERE 1 = 1
 AND table1.incoming_date >= DATE_SUB(DATE_SUB(CURDATE(),INTERVAL DAY(CURDATE()) - 1 DAY),INTERVAL 3 MONTH)

Most probably it is because INTERVAL is not supported in Hive with DATE_SUB(). So, can someone convert this part for me.

Error:

ParseException: 
extraneous input 'DAY' expecting {')', ','}(line 179, pos 60)
1 Answers

Perhaps you can do this using a combination of Hive date functions date_sub and add_months.

beeline> select current_date today, add_months(date_sub(current_date,1),-3) past_date;
INFO  : OK
+------------+-----------+
|   today    | past_date |
+------------+-----------|
| 2020-08-13 | 2020-5-12 |
+------------+-----------|
1 row selected (0.101 seconds)
Related