Skip to content

Year_ISO function does not work for end of certain years #12

@majkrebs

Description

@majkrebs

The YEAR_ISO(ADATE DATE) function handles the first few days of the year but it does not handle the end of the year correctly. For example:
2019-12-30 is ISO year 2020 but returns 2019. My suggestion is:

CASE WHEN DAYOFYEAR(ADATE) <= 7 AND WEEK_ISO(ADATE) >= 52
    THEN YEAR(ADATE) - 1
    when dayofYear(adate) >= 363 and week_iso(adate) = 1
      then year(adate) + 1
    ELSE YEAR(ADATE)
end

363 is the earliest day of the year that can be the next year.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions