List of months and years

How i can get list of months and years from my tables(ex. tab1), when i have start date ex. 072003 and end date ex. 042005 . That i use in report 6i.. . .
months | years| . . . . .
----------------------------------

If i am not wrong you want these result
SQL> SELECT hiredate FROM emp;
HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
19-APR-87
17-NOV-81
08-SEP-81
23-MAY-87
03-DEC-81
03-DEC-81
23-JAN-82
14 rows selected.
SQL> INSERT INTO emp (empno,hiredate,deptno) VALUES (1,SYSDATE,10);
1 row created.
SQL> COMMIT;
Commit complete.
SQL> SELECT hiredate FROM emp;
HIREDATE
17-DEC-80
20-FEB-81
22-FEB-81
02-APR-81
28-SEP-81
01-MAY-81
09-JUN-81
19-APR-87
17-NOV-81
08-SEP-81
23-MAY-87
03-DEC-81
03-DEC-81
23-JAN-82
01-SEP-06
15 rows selected.
SQL> SELECT TO_CHAR(a,'MON-YYYY') b FROM
  2  (SELECT ADD_MONTHS(TRUNC(sysdate,'YYYY'),(rn.r-1)) a FROM
  3  (SELECT ROWNUM r FROM user_objects WHERE ROWNUM<=12) rn)
  4  MINUS
  5  SELECT TO_CHAR(hiredate,'MON-YYYY') FROM emp;
B
APR-2006
AUG-2006
DEC-2006
FEB-2006
JAN-2006
JUL-2006
JUN-2006
MAR-2006
MAY-2006
NOV-2006
OCT-2006
11 rows selected.
SQL> SELECT b FROM
  2  (SELECT TO_CHAR(a,'MON-YYYY') b FROM
  3  (SELECT ADD_MONTHS(TRUNC(sysdate,'YYYY'),(rn.r-1)) a FROM
  4  (SELECT ROWNUM r FROM user_objects WHERE ROWNUM<=12) rn)
  5  MINUS
  6  SELECT TO_CHAR(hiredate,'MON-YYYY') FROM emp)
  7  WHERE b BETWEEN 'NOV-2006' AND 'SEP-2006';
B
NOV-2006
OCT-2006
SQL> Khurram

Similar Messages

  • 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

  • Display month and year in dropdown list on selection screen

    Hi
      Can anyone tell me how to display months and year in a dropdown list on a selection screen?
      also please tell me how to get the first and the last dates upon selecting the month and year on the dropdown list.
    Month: January Year:2007 . 
    After selecting the required month and year, the first date and last date i.e '01.01.2007 - 31.01.2007' should be displayed on the right side.
    Reward Points assured..
    thanks,
    Chetan

    Hi..,
    <b>
    Just copy, paste and execute this program !!</b>
    type-pools: vrm.
    parameters : p_month(2) type n as listbox visible length 10,
    p_year(4) type n as listbox visible length 10.
    DATA : W_DATE type d, w_ldate type d.
    initialization.
    perform user_drop_down_list_fordt.
    perform user_drop_down_list_foryr.
    start-of-selection.
    concatenate p_year p_month '01' into w_date.
    call function 'BKK_GET_MONTH_LASTDAY'
      exporting
        i_date        = w_date
    IMPORTING
       E_DATE        = w_ldate
    write /: w_date,w_ldate.
    build user_drop_down_list
    form user_drop_down_list_fordt.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    data: t_months type t247 occurs 0 with header line.
    clear list. refresh list.
    name = 'P_MONTH'.
    select * into  table t_months
    from t247 where spras eq 'EN'.
    sort t_months ascending by mnr.
    loop at t_months.
    clear value.
    value-key = t_months-mnr.
    value-text = t_months-ltx.
    append value to list.
    endloop.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    for year...
    form user_drop_down_list_foryr.
    data: name type vrm_id,
    list type vrm_values,
    value like line of list.
    clear list. refresh list.
    name = 'P_YEAR'.
    do 9999 times.
    clear value.
    value-key = sy-index.
    append value to list.
    enddo.
    Set the values
    call function 'VRM_SET_VALUES'
    exporting
    id = name
    values = list.
    endform.
    <b>
    Hope this solves ur problem..</b>
    regards,
    sai ramesh

  • DRQ: Isolate the Daily, Monthly and Yearly CheckBoxes in Selection Criteria

    Module: Financials => Financial Reports => Accounting => General Ledger
    Request to Isolate the Daily, Monthly and Yearly Check Boxes in the General Ledger - Selection Criteria screen, instead of an option in the report window.
    Problem:  If there is BP/General Ledger having long transaction list, then once user un-check any of the check boxes system takes long time to remove/hide those rows which contains Totals. Which is effecting the performance of the report also.  Also those checkboxes appeared with check marked by default.
    If user has an option in the selection criteria screen, then they can choose which Total they want before previewing the report and mark accordingly.
    Thanks & Regards
    Anjan Bhowmick

    Being reached to 10 open question, I am forced to close this thread

  • How to have more months and years appear for selection in the archives for blog posts?

    Hello,
    How to have more months and years appear for selection in the archives for blog posts?  It just shows past 3 months in the year 2014, but we have many blog posts in years 2013, 2012 and 2011 and further back.  I am using the OOB SharePoint blog
    feature.
    Paul

    Hi,
    Thanks for the reply; it doesn't add anything as RSA6 was one of the options I listed and this was my fall back option if there was no other special treatment for the COPA datasources.
    I have found out why this, and other fields, are not available in KEB0.  The program uses a Function called KERA_COPA_METADATA_INTERFACE within which there is a section that selects the COPA fields:
    ***** 1. RULES (choice/class)
    * set rules for fixed fields
      PERFORM COPA_SET_RULES_FIXED_FIELDS USING I_ACCTCOST
                                          CHANGING E_T_RULES[].
    When you look at this code section there is a hard coded list of fields to exclude:
      MRULE 'MANDT     ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PAOBJNR   ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PASUBNR   ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PAPAOBJNR ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PAPASUBNR ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'HRKFT     ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'HZDAT     ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'USNAM     ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'RKESTATU  ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'TIMESTMP  ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PERDE     ' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'PERIO     ' OBLIGATORY CHAR_CE3 OBLIGATORY CHAR_CE3.
      MRULE 'COPA_AWTYP' NEVER FORGET_IT NEVER FORGET_IT.
      MRULE 'COPA_AWORG' NEVER FORGET_IT NEVER FORGET_IT.
    As this is a standard delivered SAP function I do not recommend that you change this code as you will invalid your SAP support and upgrade paths.
    Thanks
    Neil

  • Getting all dates of a particular month and year

    I want to get list of all dates of a particular month and year .
    How to get using Calendar List?

    Create a Calendar object. Set it's month and year. Then call getActualMaximum(Calendar.DAY_OF_MONTH); on the Calendar object. That will tell you how many days are in the month of that year.

  • Returning  'Day' value based on month and year parameters

    Hi,
    Is there a code that would return an end of the month  Day value based on month and year parameters?
    For example if my parameters yield 9 or September for a month value and 08 or 2008 for the year value, can a formula generate a value of 30 (the last day of the given month in the specific year)?
    This way the formula would pick up the different last day of the month in February for the leap years.
    Thank you.
    Vic

    1. Open the formula workshop.
    2. From the Repository Custom Functions, under Crystal and then Date, RIGHT click on cdlastdayofmonth, click on ADD TO REPORT.
    3. Create a new formula, in the formula workshop, under FUNCTIONS, go down the list till you see "CUSTOM FUNCTIONS", expand that till you see cdlastdayofmonth.
    4. In your formula, type cdlastdayofmonth(currentdate)
    5. Save and close and display the formula in your report, you should see 11/30/2008.
    If you want just the day then modify the formula to:
    totext(day(cdlastdayofmonth(currentdate)),0,'','');
    since you have parameters for month and year, do this:
    totext(day(cdlastdayofmonth(date({?year},{?month},01))),0,'','');
    to give you the last day of the month.

  • Needing a multi-month and year-in-view option for ical!

    Hello all!
    I could really use a multi-month and year-in-view format in ical... I've seen some dated posts - is anyone aware of any new developments/options for this?
    thanks and peace-
    DW

    I turn off all calendars but the birthdays. Select [Print]. Choose all the months you want to see. Deselect all calendars but birthdays. Click [Continue]. On the next menu, go to "Layout", select how many pages to print on the paper. I usually print a border around each calendar then you're good to go!
    By only printing the birthdays calenar, you won't get too many appointments to get in the way of brain storming and future planning, yet the computer still thinks its printing a useful calendar.

  • How to get Week,Month and Year details from a date column

    Hi frenz,
    I've a column like tran_date which is a date column..... I need the next week details based on this column and so on...
    I need month and year details as well based on this tran_date column.... can any one tell me how...
    Thanks in advance

    My example for objects:
    create or replace type date_object as object
      centure number,
      year    number,
      month   number,
      day     number,
      hour    number,
      minute  number,
      second  number,
      daypart number,
      week    number,
      constructor function date_object(p_dt date)
        return SELF as result
    create or replace type body date_object is
      constructor function date_object(p_dt date)
        return SELF as result
      as
      begin
        SELF.centure:= trunc(to_char(p_dt,'YYYY')/100);
        SELF.year:=    to_char(p_dt,'YYYY');
        SELF.month:=   to_char(p_dt,'MM');
        SELF.day:=     to_char(p_dt,'DD');
        SELF.hour:=    to_char(p_dt,'HH24');
        SELF.minute:=  to_char(p_dt,'MI');
        SELF.second:=  to_char(p_dt,'SS');
        SELF.daypart:= p_dt-trunc(p_dt,'DD');
        SELF.week:=    to_char(p_dt,'IW');
        return;
      end;
    end;
    select date_object(sysdate),
           date_object(sysdate).year
    from dual;Regards,
    Sayan M.

  • Sales report for current month and year a go month

    i could you please guide me builting report for current monthwise for current month and year a ago month
    report parameter month_year='06-2010'
    tables = sales and below are the table fields
    customer_id
    invoice_dt
    invoice_am
    thanks
    nhm

    Okay, Still you did not mention how you will pass value in report while generating.
    Anyway the query with UNION ALL will work. For Example.
    I am assuming that the parameter for date/month you will pass in range like 01-JUN-2010 to 30-JUN-2010
    SELECT customer_id, SUM(curr_value) curr_value, SUM(past_value) past_value
    FROM
    SELECT customer_id, NVL(SUM(invoice_amount),0) curr_value, 0 past_value
    FROM sales
    WHERE invoice_dt BETWEEN :P_FROM_DATE AND :P_TO_DATE  -- here P_FROM_DATE and P_TO_DATE will be the date range for current year as i showed above.
    AND  -- Any Condition goes here...
    GROUP BY customer_id
    UNION ALL
    SELECT customer_id, 0, NVL(SUM(invoice_amount),0)
    FROM sales
    WHERE invoice_dt BETWEEN ADD_MONTHS(:P_FROM_DATE,-12) AND ADD_MONTHS(:P_TO_DATE,-12) -- This add_months function for the previous year same month.
    AND -- Any condition goes here...
    GROUP BY customer_id
    GROUP BY customer_idNow using the above query you can design the tabular report as you showed the format.
    -Ammad
    Edited by: Ammad Ahmed on Jul 3, 2010 7:55 PM
    added GROUP BY

  • Daily, Monthly, and Yearly Report

    Hi I am new to the BAM. I have a BPM process. I want to generate the daily, monthly and yearly report for it. Please advise how can I achieve it. I have a one dimension variable on the process.
    Thanks in advance!

    Hi,
    Try this query to get default ware house and its quantity and modify above query.
    SELECT T0.[ItemCode], T0.[WhsCode], T0.[OnHand] FROM OITW T0  INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[WhsCode] =  T1.[DfltWH] and  T1.[ItemCode]  = [%0]
    Thanks & Regards,
    Nagarajan

  • 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

  • Fetching month and year from CV of Time dim

    Hi,
    I am working on BPC 7 MS version, SP3. I need to fetch Month and Year values from my Current View (i.e., %TIME_SET%) .... and if the month is AUG and year is Current I then want a logic to run... Is this possible??
    I have written the following code, and only if i hardcode the time (WHEN TIME IS 2009.AUG) the logic seems to work. But I want it to be dynamic
    *XDIM_MEMBERSET ACCOUNT=INC_REC_IN_AD
    *XDIM_MEMBERSET TIME=%YEAR%.AUG,%TIME_SET%
    *XDIM_MEMBERSET CATEGORY=ACTUAL
    *WHEN ACCOUNT
    *IS *
    *WHEN TIME.MONTHNUM
    *IS 8
    *FOR %YEAR%=%TIME_SET%.YEAR
    *FOR %MONTH%=AUG,SEP,OCT,NOV,DEC
    *REC(FACTOR=1/5,TIME="%YEAR%.%MONTH%",ACCOUNT="TEMPSTUDYEDU")
    *NEXT
    *NEXT
    *ENDWHEN
    *ENDWHEN
    *COMMIT
    Thanks,
    Prasanth.

    I think your formula is correc the %YEAR% is not a valid, Can you trap that and see what is being passed, you may also try to split the year out of %TIME%
    hope it helps.

  • Month and Year in Input Field

    Hi Gurus,
    I m Using SPMON(Period to analyze month and year) as input Field in my BSP Application.
    If i Click the Input Help i want to call a Function module "popup_to_display_month" ..
    How to acheive this.
    I have used onValueHelp attribute in which it will call only the Javascript.
    Please guide me...
    Thanks n Regards
    Aravindh

    Hi Aravindh,
    First thing if this FM 'POPUP_TO_SELECT_MONTH' gives a popup in SAPGUI , you can not use it in BSP since SAP GUI popups are not supported in BSP.
    I have used onValueHelp attribute in which it will call only the Javascript.
    If triggering a server side event using onValueHelp solves you  problem that you can do it as follows..
    1)In the layout somewhere use a blankimage that will not be visible in UI.
    2)Suppose ID of this image is 'blank'
    now call javascript function for onValueHelp
    and in this javascript function use
    dacument.getElementById('blank').click();
    change dacument to document.
    This will trigger a server event which you can process in onInputProcessing and call the FM.
    Regards,
    Anubhav

  • Data element for Month and Year

    Hello All,
    Is there any data element which will have only Month and Year.
    I have to introduce this field in a table. It should have convesion exits also.
    Ex: If i give 092009, it sould come like 09.2009
    Thank you.
    Best Regards,
    Sasidhar Reddy Matli.

    Kindly Try this code for Month and year as input and having standard F4 help..
    INCLUDE RMCS0F0M.
    TYPES : BEGIN OF TY_SELECT,
              MONTH TYPE FTI_MONTH_YEAR,
            END OF TY_SELECT.
    DATA : WA_SELECT TYPE TY_SELECT.
    SELECTION-SCREEN : BEGIN OF BLOCK SANDEEP WITH FRAME.
      SELECT-OPTIONS : S_MONTH FOR WA_SELECT-MONTH OBLIGATORY NO INTERVALS NO-EXTENSION.
    SELECTION-SCREEN : END OF BLOCK SANDEEP.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_MONTH-LOW.
      PERFORM MONAT_F4.
    SANDEEP JAIN

Maybe you are looking for