financial year sql statement please help

  • You are only given the transaction date in your transactions table and your client requires you to be able to show them their data by Financial Year, Quarter, Month, Week and Week Day

    Write the script that will enable you to create the new values for each of the measures listed above. The financial year end is 28 February 2011

    Then confirm the Financial Year, Quarter, Month, Week and Weekday.

    CREATE PROCEDURE Fin_Year1

    @Cost_date date = '2011-02-15 00:00:00.0000000'

    AS

    BEGIN

    DECLARE @Fin_year int

    DECLARE @Fin_quarter int

    DECLARE @fin_Month int

    DECLARE @Fin_Week int

    DECLARE @Weekday Varchar (25)

    set @Fin_year = DATEDIFF(year, '2010-02-28 23:59:59.9999999'

    , '2011-02-28 00:00:00.0000000');

    set @Fin_quarter = DATEDIFF(quarter, '2010-02-28 23:59:59.9999999'

    , '2011-02-28 00:00:00.0000000');

    set @fin_Month = DATEDIFF(MONTH, '2010-02-28 23:59:59.9999999'

    , '2011-02-28 00:00:00.0000000');

    set @Fin_Week = DATEDIFF(WEEK, '2010-02-28 23:59:59.9999999'

    , '2011-02-28 00:00:00.0000000');

    set @Weekday = DATEDIFF(WEEKDAY, '2010-02-28 23:59:59.9999999'

    , '2011-02-28 00:00:00.0000000');

    SELECT @Fin_year as FinancialYr ,@Fin_quarter as FinancialQtr , @fin_Month as FinancialMnth , @Weekday as Wekkeday

    END

    GO

  • Is this homework or a real life problem?

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • please help i have been trying for many times it's my position test

  • engstevo (7/3/2013)


    please help i have been trying for many times it's my position test

    You need to find this out on your own. Nobody can help you on your test except yourself.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • So is this a homework assignment? There are missing details here, like what is the type of accounting periods are they expecting, calendar based or something like a 4-4-5 accounting? It if is calendar, then a solution is not too bad you just use a case statement for the January month in terms of changing some of its values. Then of the remaining you need to compensate for the offset.

Viewing 5 posts - 1 through 4 (of 4 total)

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