Created 12-17-2015 10:33 AM
Hi everyone, In my hive table i have values in one column are like " Thu Dec 17 15:55:08 IST 2015 " .For this particular column i would like to find "week of the year".How can i do that one .Assume column name is survey_date and data type is string.
Created 12-17-2015 12:51 PM
Try this:
select weekofyear(from_unixtime(unix_timestamp('Thu Dec 17 15:55:08 IST 2015', 'EEE MMM d HH:mm:ss Z yyyy'),'yyyy-MM-dd')) from sample_07 limit 1; select weekofyear(from_unixtime(unix_timestamp('Thu Dec 02 15:55:08 IST 2015', 'EEE MMM d HH:mm:ss Z yyyy'),'yyyy-MM-dd')) from sample_07 limit 1;
Created 12-17-2015 12:51 PM
Try this:
select weekofyear(from_unixtime(unix_timestamp('Thu Dec 17 15:55:08 IST 2015', 'EEE MMM d HH:mm:ss Z yyyy'),'yyyy-MM-dd')) from sample_07 limit 1; select weekofyear(from_unixtime(unix_timestamp('Thu Dec 02 15:55:08 IST 2015', 'EEE MMM d HH:mm:ss Z yyyy'),'yyyy-MM-dd')) from sample_07 limit 1;
Created 12-18-2015 05:33 AM
I guess,from_unixtime function has to convert bigint to "yyyy-MM-dd" not "yyyy-mm-dd".
Created 12-18-2015 10:19 AM
@Suresh Bonam you are right. I updated the answer. Thank you!