re: date_format()
This was a pain in the neck to originally research and code until I realized that GM did most of the work already with its week number (which appeared to be ISO 8601 compliant). I saw an example tonight that may show ISO 8601 week numbers and year numbers are not being calculated corrected here. Need to do some more research.
https://derickrethans.nl/iso-8601-weeks.html