Search code examples
sqldatehivehiveqlhue

Previous day of current_date() in Hue hive


I'm trying to write a query to return records from a column called "businessdate" (which is in the YYYY-MM-DD format, and it is a string data type), using the previous days "businessdate" records and am stuck. I've tried different things, and I get error messages ranging from argument or matching method, etc. It's probably simple, and I feel dumb. Please help!

Query;

Select businessdate from dbname
Where businessdate = current_date - 1

Solution

  • Use date_sub function to subtract one day from current_date:

    select businessdate 
      from dbname.tablename
     where businessdate = date_sub(current_date,1)