Just to round this off a bit, YYYY returns the "week year", or the year that a week belongs to. (As far as I can make out) Week 1 contains the 1st January and since that's a Wednesday in 2025 the preceeding Monday and Tuesday are also in Week 1 of 2025. So (for my locale, Ireland), I get,
dateFormat(toDate("2024-12-29 08:00:00"), "YYYY") → 2024
dateFormat(toDate("2024-12-30 08:00:00"), "YYYY") → 2025
dateFormat(toDate("2024-12-31 08:00:00"), "YYYY") → 2025
dateFormat(toDate("2025-01-01 08:00:00"), "YYYY") → 2025
Figure 1. Week 1 of 2025 contains the last two days of 2024, so the Week Year is 2025 for those two dates.
There's some discussion over on StackOverflow which goes into some detail - but who has time?
