A lot of fiddling about, but the select year and week now works,
although needs to be tested and refactored!