Get Fiscal Week Number

  • CELKO (4/30/2015)


    mm7861 (4/29/2015)


    I am using a calendar table. The code is intended for a stored procedure that will populate the calendar table.

    Your mindset is still locked in procedural coding and not data and set oriented programming.

    You are going to do this once, so just use a spreadsheet. I would also add the ISO-8601 week day to the Calendar (yyyyWww-d) to make searching and aggregation easier.

    You might be able to get it done faster in a spreadsheet, but then again what's the fun in that? And you might learn something coding it yourself 🙂

  • From what you've said, I think its also important to determine when your fiscal "week 1" ends. Since your fiscal "Day 1" could be any day of the week, then does your "week 1" always run for 7 days, or does it end on a fixed day of the week, say, the Sunday? If the latter, then your "week 1" could comprise anything from 1 to 7 days , whereupon you would move into "week 2". (And you may well run into a "week 53" before you hit the start of the next fiscal year.)

    Once you have determined the above, you may find that DATEDIFF(week,.....) isn't going to work for you since it will always assume Sunday is the first day of the week - irrespective of your SET DATEFIRST option. In that case, i suggest you may have to use DATEDIFF (day,....) and then divide by 7.

  • Now we know why the ISO Week was born. Removes a whole lot of all this guessing.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Why have ISO when you can have Her Majesty's Revenue and Customs! 🙂 🙂 🙂

    http://www.taxadvisorypartnership.com/tax-compliance/why-does-the-uk-tax-year-start-on-6-april-each-year/

  • andyscott (5/5/2015)


    Why have ISO when you can have Her Majesty's Revenue and Customs! 🙂 🙂 🙂

    http://www.taxadvisorypartnership.com/tax-compliance/why-does-the-uk-tax-year-start-on-6-april-each-year/

    Owwww!!!! So THAT's where that date comes from!

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I too am totally surprised of the fact that I have never known this!

  • CELKO (5/5/2015)


    Seeing this weird fiscal calendar really intrigues me - never seen or heard of this one.

    I wonder how many different fiscal calendars there are out there in the real world.

    The last count I saw years ago was 157 for the GAAP. This is why I say get a spreadsheet from the accounting department and put into a table.

    A quick peak at http://en.wikipedia.org/wiki/Fiscal_year seems to indicate that there are essentially 4 with the UK and Iran each throwing in a weird start date.

    But this GAAP inventor is an interesting guy...

  • Michael Meierruth (4/30/2015)


    Seeing this weird fiscal calendar really intrigues me - never seen or heard of this one.

    I wonder how many different fiscal calendars there are out there in the real world.

    I wonder what fiscal calendars the Chinese use or - the Russians - the Iranians?

    It's a never ending story...

    BTW, why does the year_day start with zero? It doesn't feel right... 🙂

    Actually, this is pretty common in the advertising industry with US businesses. A large number of businesses depending on the industry have very diverse fiscal calendars that have different start dates and intervals. Most of the common fiscal calendar scripts out there do not help. I had to develop my own from a collection of others that fit my needs.

    I think the reason why depends on the industry and depends on how you want to report on your spending/earnings. Controlling the time aspect of how you report those spending/earnings is a pretty critical piece. It's likely why there is no standard among everyone.

  • In the '90s, I worked for a company where the fiscal year started on the founder's birthday, March 23.

    Don Simpson



    I'm not sure about Heisenberg.

  • The previous company I worked for had their Fiscal Year starting on March 1st, holiday year starting on July 1st, and KPI year starting on November (the month the company started). Madness!

Viewing 10 posts - 16 through 24 (of 24 total)

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