[英]Want week number from different columns of Year, Month & Day
I want week number from different columns of Year, Month & Day in same table of Hive QL.我想要 Hive QL 同一张表中年、月和日不同列的周数。 IF you can give logic on SQL, that's also fine.
如果您可以在 SQL 上给出逻辑,那也没关系。
Concatenate the date, month and year into a proper date format and apply weekofyear().将日期、月份和年份连接成适当的日期格式并应用 weekofyear()。
Select weekofyear(cast(concat(year,"-",month,"-",date) as date)) from tablename.
Please note that I have used cast to convert the concatenated string into date.Howver, you might need to use different method based on your date format.请注意,我使用强制转换将连接的字符串转换为日期。但是,您可能需要根据您的日期格式使用不同的方法。 Please refer to the below answer on handling string conversion to date formats.
请参阅以下有关处理字符串转换为日期格式的答案。
Hive cast string to date dd-MM-yyyy Hive 将字符串转换为日期 dd-MM-yyyy
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.