Query for fiscal month till current month of year

Hi,
can you please help me to show only fiscal months till current month of year?
e.g. Current month is Apr of 2012.
I have to show the fiscal months till the Apr 2012 of year 2012.
if the date is 24th of Apr then it would show May month also.
Regards,
Nilesh

with t as (
select to_date('04232012','MMDDYYYY') d from dual union all
select to_date('04252012','MMDDYYYY') from dual)
select
d,
case
when to_char(d,'DD') >= 24 then
to_char(trunc(add_months(d,1),'MONTH'),'MM-YYYY')
else
to_char(d,'MM-YYYY')
end fin_month
from t
D     FIN_MONTH
23.04.2012     04-2012
25.04.2012     05-2012

Similar Messages

  • Function module reqd for fiscal period using current date

    Hi,
    Is there any function module which gives fiscal period using current date.
    Thnaks,
    Maheedhar

    Hi Maheedhar,
    Try the code below.
    CALL FUNCTION 'GET_CURRENT_YEAR'
      EXPORTING
        BUKRS         = '1000'     " Company Code
        DATE          = SY-DATUM   " Date to find fiscal year for
      IMPORTING
        CURRM         = w_currm    " Current Fiscal Month
        CURRY         = w_curry    " Current Fiscal Year
        PREVM         = w_prevm    " Previous Fiscal Month
        PREVY         = w_prevy.   " Previous Fiscal Year
    Regards,
    Amit.

  • How to design for YTD, Monthly & Last year Key figures

    Hi Gurus:
    Can you pls tell me how to design a data model, where a user wants to get YTD, Monthly & Last year Key figures say Sales volume...
    Is aggregates the answer?
    Pls let me know...Thanks a lot

    Hi Vijay,
    I am a beginner in BI field.
    I have a problem till now i couldnt get the right answer.
    That the reason why i write you today.
    My Problem is with a Query.
    I'm designed a dynamic query which should look like this:
    12.2005-- Jan06 --- Feb06 --- Mar06 --- Apr06 ... Dec06 --- YTD
    My Problem, if you give per e.g Dezember, all Months have to appear. Or you give may, your going to receive till may.The result i receive till now its only the month i gave.How can i get the correct answer? How i am going to calculate the YTD?
    You can directly answer hier:[email protected]
    Thanks

  • Table for Material Quantity and Value for particular month and year

    Hi All
    My requirement is that for a particular month and year I want to know the stock quantity and stock value for a particular material for a given plant.From which SAP table can I get this data as I want to fetch data for my Y report?
    Regards
    Satish Kumar

    Hi,
    You can use MB5B table as suggested earlier.also you can use:
    MBEW-VMKUM --> stock for previous month period
    MBEW-VJKUM --> stock for previous year period
    PLease view these links which migh tbe helpful to you:
    http://help.sap.com/saphelp_47x200/helpdata/en/39/55fee3bc6111d4b3960050dadf0791/content.htm
    TableStock
    Thanks
    Nisha

  • Function module for getting month and year of the previous month (say -6)

    Hi,
    Is there a function module that will get you the month and year of say, a month before, and as far as 11 months ago.
    For example, say today is 6/2007. I want 7 months ago.
    How do i get this value?
    What function module or method is available?
    Points will be rewarded and responses will be appreciated.
    Thank You,
    John

    Hi
    lv_period gives the month and year which is two months earlier now as we have specified lv_months as -2.
        DATA: LV_PERIOD LIKE S001-SPMON,
              LV_MONTHS(2) TYPE C VALUE '2-',
              LV_DATUM LIKE SY-DATUM,
              LV_NEWDT LIKE SY-DATUM,
            P_SPMON LIKE S001-SPMON VALUE '200601'.
        CONCATENATE P_SPMON '01' INTO LV_DATUM.
        LV_PERIOD = P_SPMON+0(6).
        CALL FUNCTION 'MONTH_PLUS_DETERMINE'
             EXPORTING
                  MONTHS  = LV_MONTHS
                  OLDDATE = LV_DATUM
            IMPORTING
                 NEWDATE = LV_NEWDT
             EXCEPTIONS
                  OTHERS  = 1.
         IF SY-SUBRC = 0.
           LV_PERIOD = LV_NEWDT+0(6).
         ENDIF.
    WRITE :/ LV_PERIOD.
    OR
    Use the following FM for getting the year and the month based on date
    CACS_DATE_GET_YEAR_MONTH
    or
    Call Function 'CCM_GO_BACK_MONTHS '.
    Funny module: 03/31/2002 - 1 month = 02/31/2002
    OR
    RE_ADD_MONTH_TO_DATE ( Add / substract month to/from date )
    Need ur reward points.
    Best regards,
    Ravi

  • Being billed for 13 months a year?

    Hi, i've got a problem I can't fathom.
    Recieved a bill (date 30thMarch) that was around twice the amount of my usual monthly bill and that stated it covered charges 1st march - 27th march and 28th march - 27th april.
    At the time i phoned up to figure out why i had been charged twice as much. I was told that this was a two month bill. which sort of made sense at the time. But i then recieved a bill in april, and i had previously recieved a bill in february.
    So where exactly is this extra month?
    The only thing i can think of is that the bill periods for each item, Broadband talk, phone line etc. are all periods of 4 weeks....Not a month.
    This means there are going to be 13 "monthly" bills in a year. Is this right? Surely the prices can't be advertised as monthly if they have to be paid 13 times a year. Any help about this would be great.

    Hi EvansG,
    Welcome to the forum and I am sorry for the confusion over your most recent bill.
    Please have a read of the information on this link How we worked out your bill.  I think that your bills have been changed to the new style billing which has included and extra one off charge to catch up to the billing period.  The link above will explain why this has happened.
    I hope this helps
    Cheers
    Sean
    BTCare Community Manager
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry that we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • How to use the API for DATE, MONTH  AND YEAR

    I would like to use the java api in .util.calender in the java api to get the date.
    How to implement the API for the "DATE","MONTH","YEAR" which are available provide by java?
    can someone give me in one complete code?

    From the Java Developers Almanac 1.4:
        Calendar cal = new GregorianCalendar();
        // Get the components of the date
        int era = cal.get(Calendar.ERA);               // 0=BC, 1=AD
        int year = cal.get(Calendar.YEAR);             // 2002
        int month = cal.get(Calendar.MONTH);           // 0=Jan, 1=Feb, ...
        int day = cal.get(Calendar.DAY_OF_MONTH);      // 1...
        int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // 1=Sunday, 2=Monday, ...

  • MMPV for last month of year

    Hi Guru's
    I am going to open MM period through MMPV for jaunary 2010.
    i am puting period = 01 and Fiscal year 2010
    and getting error message that " 2010 is not your current cleander year.
    so what is my fiscal year in this case??
    seeking your help.
    Regards,

    Hi
    Check it out in the FI whether they opened the fiscal year in FI or not. Check with transaction OB52, whether FI has opened their periods or not.
    If not, then let them opened it first then you have to open MM period.
    Regards
    Imran

  • KM Search: How can I define a query for the user who currently logged on?

    Hello,
    I want to use the KM Search iView to display all documents from the currently logged on user in a certain sort order. The result should be some kind of report for the user...
    In the search option I can define a default sort order. And I can also define it for a special user with cm_modifiedby(value=username)
    But how can I define the predefined property value generically for the current user?
    I tried to insert following values in the parameter Predefined Properties of the search option:
    Predefined Properties (csv): cm_modifiedby(value=<user.id>)
    Predefined Properties (csv): cm_modifiedby(value=%user.id%) -> like in the predefined properties
    Predefined Properties (csv): cm_modifiedby(value=$sap_user) -> like in the xml forms builder
    But non of these 3 parameters worked. Has anybody an idea what the right variable is?
    Thanks a lot.
    Best regards
    Nicole

    Hi Nicole,
    1. First of all you need to use "<User.UserID>" to get the currently logged on user.
    2. You need to create an AppIntegrator iView (so based on com.sap.portal.appintegrator.sap.Generic) in order to be able to use this dynamical parameter. The parameter "URL template" should look like:
    <Request.Protocol>://<Request.Server>/irj/servlet/prt/portal/prtroot/com.sap.km.cm.basicsearch?layoutSetMode=exclusive&ResourceListType=com.sapportals.wcm.SearchResultList&SearchType=quick&rndLayoutSet=SearchResultLayoutSet&SearchCompsName=UISearchComponents&QueryString=*&SelectedCustomProps=cm_modifiedby(value=<User.UserID>)
    Best regards,
    Robert

  • Date shows as correct day-January(for any month)-correct year;

    For example: 2011-09-05 shows as 5 January 2011.
    This is transferred onto all date stamps on documents in mail, i-photo etc
    In mail inbox I can correct the issue by narrowing the time, date column, wwhich then shows correct numerical date values, but 'January' is still incorrectly printed on reply emails etc.
    This is a serious problem as we have to keep logs of correspondence etc.
    Has anyone experienced a similar problem?

    System Preferences>Language & Text>Formats.
    Set it up the way you want it.

  • Query sales per month per customer

    Hello,
    I have a query for the months january and february working. Now I want to add more months.
    When I do this, the query works, BUT I get very strnage amounts.
    Instead of 20,000 I get an amount of 1.650.000
    Can someone please tel me where I go wrong?
    SELECT T0. [CardCode] ,
    T0. [CardName] ,
    (SUM (T1.Debit) - SUM (T1.Credit ) ) AS ' [November 2013] ' ,
    (SUM (T2.Debit) - SUM (T2.Credit ) ) AS ' [December 2013] ' ,
    (SUM (T3.Debit) - SUM (T3.Credit ) ) AS ' January ' ,
    (SUM (T4.Debit) - SUM (T4.Credit ) ) AS ' February ' ,
    (SUM (T5.Debit) - SUM (T5.Credit ) ) AS ' March ' ,
    (SUM (T6.Debit) - SUM (T6.Credit ) ) AS ' April '
    FROM dbo.OCRD T0
    LEFT JOIN dbo.JDT1 T1 ON T1.ShortName = T0. CardCode AND Month (T1.DueDate ) = 1 AND Year (T1. DueDate ) = Year (GetDate ( ) ) AND T1. TransType in (13, 14)
    LEFT JOIN dbo.JDT1 T2 ON T2.ShortName = T0. CardCode AND Month (T2.DueDate ) = 2 AND Year (T2. DueDate ) = Year (GetDate ( ) ) AND T2. TransType in (13, 14)
    LEFT JOIN dbo.JDT1 T3 ON T3.ShortName = T0. CardCode AND Month (T3.DueDate ) = 3 AND Year (T3. DueDate ) = Year (GetDate ( ) ) AND T3. TransType in (13, 14)
    LEFT JOIN dbo.JDT1 T4 ON T4.ShortName = T0. CardCode AND Month (T4.DueDate ) = 4 AND Year (T4. DueDate ) = Year (GetDate ( ) ) AND T4. TransType in (13, 14)
    LEFT JOIN dbo.JDT1 T5 ON T5.ShortName = T0. CardCode AND Month (T5.DueDate ) = 5 AND Year (T5. DueDate ) = Year (GetDate ( ) ) AND T5. TransType in (13, 14)
    LEFT JOIN dbo.JDT1 T6 ON T6.ShortName = T0. CardCode AND Month (T6.DueDate ) = 6 AND Year (T6. DueDate ) = Year (GetDate ( ) ) AND T6. TransType in (13, 14)
    WHERE T0. CardType = 'C'
    Group By T0. [CardCode] , T0. [CardName]

    Hi,
    Please check any manual journal entry posted for that month.
    Thanks & Regards,
    Nagarajan

  • F4 option for Month and Year

    hi
    In Selection Screen i have Month and Year as input.....
    How to give "F4" Option for both Month and Year?
    Regards
    Smitha

    hi,
    this will help u get the month in f4 help .
    similarly u can fill up the itab for year and get that f4 help too i guess.
    TABLES: T247 ,
            DFIES.
    PARAMETERS:P_MONTH LIKE T247-MNR.
    DATA: BEGIN OF ITAB OCCURS 0,
    MNR LIKE T247-MNR,
    KTX LIKE T247-KTX,
    END OF ITAB .
    DATA : LT_FIELDS TYPE TABLE OF DFIES,
           LWA_FIELD TYPE DFIES.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_MONTH.
      SELECT MNR
             KTX
      FROM T247 INTO CORRESPONDING FIELDS OF TABLE ITAB
      WHERE SPRAS = 'EN'.
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          RETFIELD    = 'P_MONTH'
          DYNPPROG    = SY-CPROG
          DYNPNR      = SY-DYNNR
          DYNPROFIELD = 'MNR'
          VALUE_ORG   = 'S'
        TABLES
          VALUE_TAB   = ITAB
          FIELD_TAB   = LT_FIELDS.

  • Find the difference between two dates for the specific month and year

    Hi,
    I have two dates, start date is 30/12/2012 and end date is 04/01/2013. Using datediff I found the difference of days between two dates. But I find the no of days in January 2013. ie output is 4 instead of 6. I input month and year to find the no of days
    for that date. In this case I input Jan 2013. How can I sql this ?

    I don't understand how most of the answers provided here not analytically solving the problem with many cases possible.
    First let me understand you:
    You have 2 dates range and you want to calculate day range for specific month and year between the original date range.
    declare @for_month int = 1 --January
    declare @for_year int = 2013
    declare @StartDate date = '2012-12-20'
    declare @EndDate date = '2013-01-04'
    SELECT
    CASE
    WHEN (DATEPART(MONTH, @StartDate) = @for_month and DATEPART(MONTH, @EndDate) = @for_month) and ((DATEPART(YEAR, @StartDate) = @for_year or DATEPART(YEAR, @EndDate) = @for_year)) THEN
    DATEDIFF(DAY, @StartDate,@EndDate)
    WHEN (@StartDate < cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (@EndDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, DATEADD(MONTH, DATEDIFF(MONTH, -1, @EndDate)-1, 0),@EndDate)
    WHEN (@EndDate > cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) and (@StartDate between (cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) and (cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date))) THEN
    DATEDIFF(DAY, @StartDate,DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, @StartDate) + 1, 0))) + 1
    WHEN ((DATEDIFF(DAY, @StartDate, cast(DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date)) + 1, 0)) as date)) >= 0) and (DATEDIFF(DAY, cast(CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as date), @EndDate) >= 0)) THEN
    DATEDIFF(DAY, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime), DATEADD(d, -1, DATEADD(m, DATEDIFF(m, 0, cast( CONVERT(varchar(4), @for_year) + '-' + CONVERT(varchar(2), @for_month) + '-01' as datetime)) + 1, 0))) + 1
    ELSE
    0
    END as [DD]
    I don't know how you calculate day range between 01/01/2013 and 04/01/2013
    is 4, it is actually is 3 but if that is the case, you can add 1 from the condition.

  • Same Query for both Main and Sub Report

    I have a report whichs works but I don't think i'm getting the data to both the Main Report and Sub Report in the most effcient manner...  I have a report that totals users call subject counts.  But then end user wishes to see all users total counts and the grand totals of call counts on the first page then then the breakdown of types of calls on subsuquent pages...  so I created a report with a subreport in the report header....  I use the same query in both the sub and main report... however it asks the user to enter the parameters once for the main report and once for the sub report... Parameters are both the same for each; month and year...  so it currently runs the query twice I want to run it once and use the data for both reports...  I group by name and then sum the call subject counts for the user totals... and in the sub report I hide the detail section and I'm just left with the sub total line for each user, then in the main report use the same grouping and suming again and I start a new page for every user... 
    Using CR 9
    Thanks for any advice
    Vincent

    i think you need to link the main report parameter with the subreport parameters inorder to pass the parameter values from main report to subreport. So right click on subreport and go to change subreport links and add parameter fields and select parameter fields from your subreport and un check the databse fields in subreport.
    Regards,
    Raghavendra.G

  • List of Month and Year in SSRS report parameter?

    Hi, I have two parameters in my SSRS Report i.e. Month and Year. I want to show the list of all Months in dropdown and years for a particular range say 1995-Current Year.
    Can any one suggest me the query for how to get it to work.Thanks!!
    MCP

    I am not sure I what you're business needs are for this report.  You stated that you need the month and year for parameters.  If this is the case then there has to be a date and time column in which you can query against to provide both the month(s) and year.  In order to accomplish this using t-sql without querying an existing column would require a loop or cursor based approach,which can negatively impact performance, or a union statement specifying a string literal and the effort to write either of these would exceed the effort required to statically assign the parameter values in reporting services.  The below query shows how to statically create a query for each month and its ordinal position in the year and the same could be done with the year(s) 1995-2009, but this process involves more resources than assigning the static values for the parameters
    SELECT DATENAME(MONTH, 1 ) AS MONTH,
    1
    UNION
    SELECT DATENAME(MONTH, 2 ) AS MONTH,
    2
    UNION
    SELECT DATENAME(MONTH, 3 ) AS MONTH,
    3
    UNION
    SELECT DATENAME(MONTH, 4 ) AS MONTH,
    4
    UNION
    SELECT DATENAME(MONTH, 5 ) AS MONTH,
    5
    UNION
    SELECT DATENAME(MONTH, 6 ) AS MONTH,
    6
    UNION
    SELECT DATENAME(MONTH, 7 ) AS MONTH,
    7
    UNION
    SELECT DATENAME(MONTH, 8 ) AS MONTH,
    8
    UNION
    SELECT DATENAME(MONTH, 9 ) AS MONTH,
    9
    UNION
    SELECT DATENAME(MONTH, 10) AS MONTH,
    10
    UNION
    SELECT DATENAME(MONTH, 11) AS MONTH,
    11
    UNION
    SELECT DATENAME(MONTH, 12) AS MONTH,
    12
    David Dye

Maybe you are looking for

  • Photoshop Elements trial download - Mac OSX 10.8.6 fatal error on installation failure

    Can anyone unravel the following and offer a simple solution please? thanks: Exit Code: 7 -------------------------------------- Summary -------------------------------------- - 0 fatal error(s), 37 error(s), 12 warning(s) WARNING: DW066: OS requirem

  • Logic Pro X Additional Content .....still installing

    Hi, I recently purchased and downloaded the new Logic Pro X then downloaded the additional content.  This took about 36 hours as my Internet Connection is only 1-2 Mb.  The dialog box then changed to.  Installing Additional Content....and has remaine

  • Order By clause is ignoring LowerCase field name

    I am trying to use a QoQ, but am running into a problem when using the order by clause... All the fieldvalues in the order by field start with uppercase except for one, and this field name gets thrown to the end of the list Anyone got any ideas??? th

  • Issues in broadcasting through sap BI.

    I am broadcasting two reports at the same time from SAP BI which is working fine. Now the issue is both these reports dont get received by the user at the same time. one is receieved at the right time but the other one is received after almost 4 hour

  • Changing font in iCloud mail

    How do I permanently change the font & font size for outgoing emails on iCloud? I can do it manually, but then iCloud mail never "remembers" that change - grr. frustrating! Anyone solve this?