hive中有没有日期函数可以选择一个月的星期?
假设一周是从周日到周六,周日是一周的开始日,周六是一周的结束日。
我有一份日期清单,从1900年1月1日到2029年12月31日。我想知道Hive中是否有一个日期函数来获取一个月中的一周。
例如。:
2019-02-01 to 2019-02-02 is the first week of FEB
2019-02-03 to 2019-02-09 is the second week of FEB..
2019-02-24 to 2019-02-28 is the 5th week of FEB
我的问题是:
select (weekofyear(date)-weekofyear(trunc(date,'month')) + 1 as Week_of_month
但是,出现了一些错误。在年初,每月的一周是负数。e、 g.1993-01-03 is-51
1条答案
按热度按时间sirbozc51#
使用
date_format(date/timestamp/string ts, string fmt)
功能。W
格式模式是指一个月内的周数。其他有用的日期和时间格式模式