简体   繁体   中英

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. IF you can give logic on SQL, that's also fine.

Concatenate the date, month and year into a proper date format and apply 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM