How to subtract one day from current date then convert to string in Hive

DATE_SUB is Available in HIVE 2.1.0

date_sub(date/timestamp/string startdate, tinyint/smallint/int days)

Subtracts a number of days to startdate: date_sub('2008-12-31', 1) = '2008-12-30'.

Prior to Hive 2.1.0 (HIVE-13248) the return type was a String because no Date type existed when the method was created.


once you parsed the date then use date_sub function that is available in hive

date_sub(string startdate, int days) 

date_sub('2008-12-31', 1) = '2008-12-30'

You can even follow the link below.

https://www.qubole.com/resources/cheatsheet/hive-function-cheat-sheet/

Tags:

Sql

Hadoop

Hive