sql - Getting last day of week from week number & year in Aginity workbench -
i working in netezza sql.
i have got week number , year in dataset combined entry. example, "week 3, 2017". want use field date last day of week. in case, should "21-jan-2017".
any thoughts on how can it?
thanks.
here's example should work you:
select date(year_num || '-01-01') + cast(((week_num * 7) - 1) || ' days' interval) (select cast(translate(substr(dt, 0, instr(dt, ', ')), 'week ', '') byteint) week_num, cast(substr(dt, instr(dt, ', ') + 2) smallint) year_num (select 'week 3, 2017' dt union select 'week 19, 2015' dt union select 'week 45, 2016' dt) _) _
Comments
Post a Comment