Hive: Filtering Data between Specified Dates when Date is a String

后端 未结 6 1410
旧巷少年郎
旧巷少年郎 2021-02-04 02:08

I\'m trying to filter data between September 1st, 2010 and August 31st, 2013 in a Hive table. The column containing the date is in string format (yyyy-mm-dd). I can use month()

6条回答
  •  深忆病人
    2021-02-04 02:56

    The great thing about yyyy-mm-dd date format is that there is no need to extract month() and year(), you can do comparisons directly on strings:

    SELECT *
      FROM your_table
      WHERE your_date_column >= '2010-09-01' AND your_date_column <= '2013-08-31';
    

提交回复
热议问题