Search code examples
hivehiveql

How to get the start date of the week by week number of year in Hive? First day of week should be Monday


I have a week number of year in ISO format and I want to get start date of this week in Hive. First date of week is Monday. Example: year 2020 week 50 - start date should be 2020-12-07


Solution

  • Try the code below, where year and week are the corresponding column names of your table.

    select date(
        from_unixtime(
            unix_timestamp(concat(year,'-',week,'-','1'), 'yyyy-w-u')
        )
    ) from <your_table_name>;