4-4-5 Calendar Functions, Part 1

  • Dr. Bob

    SSC Rookie

    Points: 37

    Cliff:

    I don't know if it was mentioned earlier, but many retail related businesses use a 4-5-4 calendar determined by the National Retail Federation (http://www.nrf.com/modules.php?name=pages&sp_id=391). Hence the division into 4-5-4 or 4-4-5 is not arbitrary. There are many anomalies that occur over the years and how they are handled is determined by this group. Hence the only easy way to handle it is by a look-up table for organizations using the NRF calendar.

    Regards

  • maddogs

    SSCrazy

    Points: 2364

    Gagne - I know this post is old but I came across it looking for a 4-4-5 fiscal calendar generator with exactly the criteria you have (Jan1-Dec31 fiscal year, periods end on Friday, etc.) but unfortunately we are still stuck with SQL 2000. Do you have a version of this code that works with SQL 2000?

    Thanks,

    Dennis


    maddog

  • Eric_Gagne

    SSCrazy

    Points: 2062

    Hi Maddog.

    I no longer have access to a SQL 2000 server to test but what's not working in my scrupt ? I reviewed it quickly and I think everything should work besides the table variables but that can replaced wiith temp tables.

    Can you run the code and show us what errors you get ?

  • maddogs

    SSCrazy

    Points: 2364

    Thanks for responding, and so quickly!

    The 'dense_rank()' and 'over(partition by' bits in the stored procedure are not functions in SQL 2000, and I don't have use of Analysis Services either unfortunately.

    Thanks,


    maddog

  • Eric_Gagne

    SSCrazy

    Points: 2062

    Yes of course, I forgot they were not SQL 2000 functions. I'm gonna check on my machine tomorrow, maybe I still have the 2000 code for this.

  • Jeff Moden

    SSC Guru

    Points: 995116

    Computers have made most date calculations a breeze. I'm amazed that companies and organizations are still stuck with the idea of week-based calculations that require such nuances as ISO weeks, 4-4-5 and 4-5-4 calculations.

    --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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

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

  • maddogs

    SSCrazy

    Points: 2364

    Sounds great, thanks 🙂


    maddog

  • dkangel

    Grasshopper

    Points: 11

    Jeff Moden - Monday, September 28, 2009 8:05 PM

    Heh... I see 3 recommendations to build a Calendar table and two that claim they've used one, yet no one has offered up any of their own code to show they have ever done so. 😉 Like the tag line from the movie goes... Show Me the Money! 😛

    I wrote code to do 4-5-4 using modulo arithmetic a long time ago.  Just never posted it.  If you are really interested I could get it to you with the caveat you attribute it to me in the comments.

  • Jeff Moden

    SSC Guru

    Points: 995116

    dkangel - Saturday, November 3, 2018 8:44 PM

    Jeff Moden - Monday, September 28, 2009 8:05 PM

    Heh... I see 3 recommendations to build a Calendar table and two that claim they've used one, yet no one has offered up any of their own code to show they have ever done so. 😉 Like the tag line from the movie goes... Show Me the Money! 😛

    I wrote code to do 4-5-4 using modulo arithmetic a long time ago.  Just never posted it.  If you are really interested I could get it to you with the caveat you attribute it to me in the comments.

    Even on a 9 year old post, this type of thing is still very much alive in the corporate world so any good input is worth its salt.  What you may want to do is formalize it all a bit and submit an article on this site.  I'm also sure that, if you ask them,  folks would be happy to do a pre-release review for you.

    --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.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."
    When you put the right degree of spin on it, the number 3|8 is also a glyph that describes the nature of a DBAs job. 😉

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

Viewing 9 posts - 31 through 39 (of 39 total)

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