本文介绍了Hive:当Date是一个字符串时,在指定日期之间过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正尝试在2010年9月1日至2013年8月31日之间过滤数据。包含日期的列是字符串格式(yyyy-mm-dd)。我可以在此列上使用month()和year()。但是如何使用它们来过滤上述日期之间的数据?
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() and year() on this column. But how do I use them to filter data between the above dates? Any examples/sample code would be welcome!
推荐答案
关于 yyyy-mm-dd
日期格式是没有必要提取 month()
和 year()
您可以直接在字符串上进行比较:
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';
这篇关于Hive:当Date是一个字符串时,在指定日期之间过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!