FISCAL_WEEK from 1 Jan till First Friday

  • Hi,

    We have one requirement. Wee need to create a fiscal_week column in SQL_server table.

    Table will have data as Normal_date column as fiscal_date and fiscal_year colum which will have year part of the date.

    Logic for FISCAL_WEEK is as below.

    - FIRST FISCAL WEEK WILL START FROM 1 JAN OF EVERY YEAR AND IT WILL BE TILL FIRST FRIDAY.

    - SECOND WEEK STARTS FROM SATURDAY AND IT WILL RUN TILL NEXT FRIDAY.

    - THIS WILL GO ON TILL THE END OF YEAR (31 JAN)

    We will Have data something as below table.

    118381-image

    How would I create query for this ? We will have data from 2010 till 2035 years in the table.

    Thanks,

    Mahesh

  • Answer will be as below.

    SET DATEFIRST 6

    GO

    SELECT FISCAL_DATE, DATEPART(WEEK,Fiscal_Date) FISCAL_WEEK FROM ERP.CUSTOM_FISCAL_CALENDER

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply