简体   繁体   English

想要年、月、日不同列的周数

[英]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.

相关问题 获取星期几,星期几,月份和年份的日期 - Get Date with Day of Week, Week Number, Month and Year 带有日期,日期,月份,年份,期间,周数的SQL表? (SQL) - SQL table with Day, Date, Month, Year, Period, Week Number? (SQL) 从Aginity工作台中的星期数和年份中获取星期的最后一天 - Getting last day of week from week number & year in Aginity workbench 我怎样才能得到从当天,当月或当年的第一天到当天的一周,一个月或一年的日期? - How could I get the the date of the week, month or year starting from the first day up to the current day of the current week, month or year? 周,月,年至周初的日期 - Week, Month, Year number to beginning of week Date 截断SQLAlchemy中的小时/天/周/月/年 - Truncate Hour/Day/Week/Month/Year in SQLAlchemy 假设每月的第一个星期一是去年该月的第一个星期一,如何计算上一年的同一天 - How to calculate previous year same day of week from month suppose first Monday of month would be last year first Monday of that month 在 SQL Server 中分别从给定的月、日和年获取工作日名称 - Get week day name from a given month, day and year individually in SQL Server 在SQL Server中的2个日期之间,每年每个月每年的天数 - Number of day Count in every week in every month year wise between 2 dates in sql server SQL中如何将年周转为年月日? - How to Convert Year-Week to Year-Month-Day in SQL?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM