What is ISO_year in sql-server

后端 未结 2 858
刺人心
刺人心 2020-12-03 16:29

I am currently working on creating my first Data_warehouse using sql-server

I have a Date dimension i want to populate it using SSIS it ha

2条回答
  •  春和景丽
    2020-12-03 17:00

    Here is a function for iso_year, the logic behind it is that the thursday of the week from the parameter date determine the year:

    CREATE FUNCTION [dbo].[f_isoyear]
    (
    @p_date datetime
    )
    RETURNS int
    as
    BEGIN
      RETURN datepart(yy, dateadd(wk, datediff(d, 0, @p_date)/7, 3))
    END
    

提交回复
热议问题