Display all quarters between 2 dates?

hi,
Is their any way to display all quarters between 2 dates.. using a SQL statement alone.. or through some function..
If so, could some one help me around on it..
1/1/2005 12/31/2006
so, the answer should be..
Q1-05
Q2-05
Q3-05
Q4-05
Q1-06
Q2-06
Q3-06
Q4-06
thanks in advance....

Hello
It looks slightly counter-intuitive (or atleast it did to me the first time I saw it) but you just need to pass the date columns of the table you want to generate the quarters for to the function:
SQL> select * from dt_test_dates
  2  /
        ID START_DAT END_DATE
         1 01-JAN-05 31-DEC-06
         2 01-JAN-07 31-DEC-08
         3 01-JAN-09 31-DEC-10
SQL> select
  2       dates.id,
  3      quarters.column_value
  4    from
  5    dt_test_dates dates,
6 TABLE( f_ListQuartersBetween(dates.start_date,dates.end_date)
7 ) quarters
  8  ORDER BY
  9     id
10  /
        ID COLUMN_VALUE
         1 Q1-05
         1 Q2-05
         1 Q3-05
         1 Q4-05
         1 Q1-06
         1 Q2-06
         1 Q3-06
         1 Q4-06
         2 Q1-07
         2 Q2-07
         2 Q3-07
         2 Q4-07
         2 Q1-08
         2 Q2-08
         2 Q3-08
         2 Q4-08
         3 Q1-09
         3 Q2-09
         3 Q3-09
         3 Q4-09
         3 Q1-10
         3 Q2-10
         3 Q3-10
         3 Q4-10
24 rows selected.It's important to note that the call to the function must come after the table that contains the dates you are interested in(at least on this version of oracle)
SQL> select * from v$version
  2  /
BANNER
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
PL/SQL Release 9.2.0.6.0 - Production
CORE    9.2.0.6.0       Production
TNS for HPUX: Version 9.2.0.6.0 - Production
NLSRTL Version 9.2.0.6.0 - Production
SQL> select
  2       dates.id,
  3      quarters.column_value
  4    from
  5     TABLE( f_ListQuartersBetween(dates.start_date,dates.end_date)
6 ) quarters,
7 dt_test_dates dates
  8  ORDER BY
  9     id
10  /
        TABLE(  f_ListQuartersBetween(dates.start_date,dates.end_date)
ERROR at line 5:
ORA-00904: "DATES"."START_DATE": invalid identifierHTH
David

Similar Messages

  • Display the report between two dates

    Hi,
    I'm new to this application.i have created two date fields item.i want to display the report between two date fields.please help me.how to do?.
    By,
    Prem.

    Prem,
    See this example:
    http://htmldb.oracle.com/pls/otn/f?p=31517:99
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to use SQL to display Datethat falls between the date range

    Hi,
    I'm figuring out how do i use SQL to select data
    that falls between the date range stated
    (for eg. 19/02/1955 to 19/02/2003)
    I've tried :
    sql="Select * From StudentRecords WHERE DOB BETWEEN #" jTextField21.getText() "#" +" And " +"#" +jTextField22.getText;
    Using BETWEEN statment , but Between Statement isn't doing what i want..
    even those out of range are displayed... any ideas how??
    Thank yOU in advance!

    oracle:
    sql = "Select * From StudentRecords WHERE DOB between TO_DATE('07/04/2003','dd/mm/yyyy') and TO_DATE('08/04/2003','dd/mm/yyyy')";

  • Lost all mail between certain dates

    I've lost all my mail between September 30 and January 14 in the in box and the sent mail.
    This is across the 3 accounts I have set up.
    The trash box holds nothing prior to January 14th.
    All very confusing, and even more annoying. Any of you smart people got any idea what could be causing this, or more importantly how I could retrieve the files.
    Many Thanks

    Let's force an overall reindexing via the removal of the Envelope Index since you say it is spread across all accounts. Note the special instructions when forcing the reindexing of IMAP or Exchange accounts in the following:
    http://docs.info.apple.com/article.html?path=Mail/3.0/en/14019.html
    This will force the reindexing of all the POP mailboxes and any On My Mac mailboxes. With regard to the IMAP account, the practical result of this action of removing the account folder, is that with the IMAP account still set up in the Preferences, Mail will connect to the IMAP server and create a new account folder, and while doing so will index the messages in the mailbox folders of the IMAP account on the server. Not removing the IMAP account folders when removing the Envelope Index file may lead to strange results -- have you by any chance ever forced a reindexing by removing the Envelope Index? This could have happened if you ever used a suggestion to remove all files except folders to cure a problem some people encountered when upgrading to 10.5.6 from 10.4.11 (was not the preferred solution however.
    May I assume that all standard mailboxes related to the IMAP account are stored on the server, as would be normal?
    Keep me posted.
    Ernie

  • Getting a list of all months between 2 DATE columns for a table

    Current set:
    IF OBJECT_ID('tempdb..#TEST') IS NOT NULL
    DROP TABLE #TEST
    CREATE TABLE #TEST
    ID INT,
    DOB DATE,
    EffectiveDate DATE,
    TerminationDate DATE,
    GCode CHAR(1)
    INSERT INTO #TEST
    VALUES
    (1043,'1/1/1970','1/1/2014','4/1/2014','S'), -- Active in month Jan,Feb,March,April
    (1051,'1/1/1989','3/1/2014','5/1/2014','P'), -- Active in month March,April,May
    (1070,'1/1/2010','5/1/2014','8/1/2014','G') -- Active in month May,June,July,August
    SELECT * FROM #TEST
    Expected result set:
    ID          Month         GCode
    1043      January      S
    1043      February    S
    1043      March         S
    1043      April           S
    1051      March        P
    1051      April          P
    1051      May          P
    ---- Similarly for ID 1070
    This is needed for the reporting and each ID will have points associated to it, that will be a separate column that I'll be adding. The reason that I want this result set is because, the user might say, how many points did the ID have for a particular month.
    The points are not going to change for an ID. Please let me know how to get the expected result set

    Try
    -- code #1
    set LANGUAGE English;
    set dateformat MDY;
    declare @Month table (N int, T varchar(20));
    declare @I int, @D date;
    set @I= 1;
    set @D= '1/1/2014';
    while @I <= 12
    begin
    INSERT into @Month values (@I, DateName(month, @D));
    set @I+= 1;
    set @D= DateAdd(month, +1, @D);
    end;
    SELECT ID, T, GCode
    from @Month as M inner join
    #TEST as T on M.N between Month(EffectiveDate) and Month(TerminationDate)
    order by ID, N;
    José Diz     Belo Horizonte, MG - Brasil

  • Determine posting to an asset between two dates

    Hello all,
    How do you calculate the postings made to an asset between two dates?  I looked at the logical database ADA, but got lost in the source code.
    For example, if these posting were made to an asset between start & end date, the total I would want would be $300.
    Post $200
    post $100
    post $200
    reserse the 2nd $200.
    Thanks
    Bruce

    Dear Friend,
    Its very easy, simply execute transaction SQV and follow the below steps
    Quick Viewer Screen appers
    Create a new quick view
    Give it a name, data source as table join, press enter.
    Press Shift+F1, put the table name ANEK and press enter
    Again press Shift+F1, put the table name as ANEP this time.
    Press F3 or back button
    Explode the Documnet Header and select List Filed and Selection Field check box for 1. Company Code 2. Main Asset Number, 3. Asset Sub Number,4. Fiscal Year, 5. Sequence Nuber, 6. Document Date or any other date on the basis of which you want to check the postings (e.g. posting date, entery date, asset valud date etc).
    Press Execute button and enter.
    A Report selection will appear, put the company code other parameters you have with you inclduing the date and execute again.
    This will give you all posting between particular date.
    Hope this solve your issue.
    Thanks!!!
    Murlidhar Khatri

  • Generate all the quarters between start and end dates

    Hello all,
    I have a query in which i have two dates that is Start Date and End Date and now i have to populates all the quarters date between the date range:
    For eg:
    Start Date : 1-Apr-2011
    End Date: 1-Jul-2012
    Now taking these two values i want the recors as displayed below
    Apr 2011
    Jul 2011
    Oct 2011
    Jan 2012
    Apr 2012
    Jul 2012
    So how can write my PL/SQL query to accomplish this task
    Thanks in advance

    958964 wrote:
    Hello all,
    I have a query in which i have two dates that is Start Date and End Date and now i have to populates all the quarters date between the date range:
    For eg:
    Start Date : 1-Apr-2011
    End Date: 1-Jul-2012
    Now taking these two values i want the recors as displayed below
    Apr 2011
    Jul 2011
    Oct 2011
    Jan 2012
    Apr 2012
    Jul 2012
    So how can write my PL/SQL query to accomplish this task
    Thanks in advanceHow do I ask a question on the forums?
    SQL and PL/SQL FAQ
    solution can be done in SQL only; no PL/SQL.

  • Display all dates between date range (Time Dimension left outer join Fact)

    All,
    I have done some searching around this issue but within all the posts regarding date variables, date prompts and date filtering I haven't seen one exactly answering my issue (maybe they are and I just dont have my head around it correctly yet).
    My report requirement is to allow a user to select a start day and an end day. The report should show all activity between those two days - AND display 0/null on days where there is no activity. That second part is where I am getting hung up.
    The tables in question are:
    TimeDim
    EventFact
    CustomerDim
    My BMM is setup as follows:
    TimeDim left outer join EventFact
    CustomerDim inner join EventFact
    If I run a report selecting DAY from TimeDim and a measure1 from EventFact with day range 1/1/2010 - 12/31/2010 .. I get a record for every day and it looks perfect because of the left outer join between TimeDim and CustomerDim.
    But .. if I add in a field from CustomerDim, select TimeDim.DAY, CustomerDim.CUSTNAME, EventFact.MEASURE1, OBIEE only returns records for the days that have EventFact records.
    This is due to the fact that the TimeDim is still outer joined into EventFact but adding in CustomerDim makes OBIEE setup an inner join between those tables which then causes only data to be returned where EventFact data exists.
    There is a way around this in this simple case and that is to define the relationship between CustomerDim and EventFact as an outer join as well. This will give the desired effect (but an outer join between these two tables is not the true relationship) and as I add additional dimensions and add additional logical sources to a single dimension in the BMM it gets complicated and messy.
    Ive also messed with setting the driving table in the relationship, etc.. but it has not given the desired effect.
    Has anyone ever encountered the need to force display all dates within a specfied range with a fact table that may not have an entry for every date?
    Thanks in advance.
    K
    Edited by: user_K on Apr 27, 2010 11:32 AM

    It worked!!!* Even my time drill downs and date based filtering still work!
    That is awesome. Never would have thought of that intuitively.
    Now, just need a little help understanding how it works. When I run my report and check the logs I can see that two queries are issued:
    Query 1: Joins the fact table to all the associated dimensions. I even changed all the relationships to inner joins (which is what they truly are). And calculates the original measure. If I copy and paste this query into sql developer it runs fine but only returns those rows that joined to the time dimension - which is what was happening before. It is correct but I wanted a record for every time dimension record.
    Query 2: Looks like the following:
    select sum(0)
    from timedim
    where date between <dateprompt1> and <dateprompt2>
    group by month *<--* this is the time dimension level specified in Query 1, so it knows to aggregate to the month level as was done in query 1
    Final Question: So what is OBIEE doing ultimately, does it issue these two requests and then perform a full outer join or something to bring them together? I couldn't see anywhere in the log a complete query that I could just run to see a similar result that I was getting in Answers.
    Thanks for all the help .. Id give more points if I could.
    K

  • Displaying all the dates eventhough there no value

    Hi Experts,
    I designed Month to date sales query, its showing day wise sales, requirement is
    when we don't have any sales on that perticular day that date will not appear(because we are getting data from cube if there no date there obviously we won't get that to query)
    but i need to show all the dates even though if there no sales.
    OR
    let me know how can we display the last 30 sales values(say today is 15.09.2010 we need to show the from today to backward 30 sales happend days) if there no sales on any date we should consider that date.
    actually this query designed for BO there are showing in graph if there no date in that graph gap will appear between the dates.
    to over come this we need to show all the dates.
    Thanks,
    Chandra.

    You'll need to create a structure containing date characteristic with selection based on variable offset.
    Example input date USER_DATE, then create entry in structure with selection offset USER_DATE-0, USER_DATE-1,... USER_DATE-30
    That way regardless whether your key figure has value or is zero, it will still be displayed.

  • Generate all Months between start and end dates using Parameter

    Hi,
    I have a query in which i have two dates that is Start Date and End Date and now i have to populates all the Months between the date range:
    Start Date : APR-12
    End Date: JUL-12
    Now taking these two values i want the recors as displayed below
    APR-12
    MAY-12
    JUN-12
    JUL-12
    So how can write my SQL query to finish this task
    Thanks

    Sounds easy with single pair of Months:
    with data(st_dt, end_dt) as
      select to_date('JAN-2012', 'MON-YYYY'), to_date('SEP-2012', 'MON-YYYY') from dual
    select add_months(st_dt, level - 1  ) mons
      from data
    connect by level <= months_between(end_dt,st_dt) + 1;
    MONS   
    01-JAN-12
    01-FEB-12
    01-MAR-12
    01-APR-12
    01-MAY-12
    01-JUN-12
    01-JUL-12
    01-AUG-12
    01-SEP-12
    9 rows selected Please ensure to read {message:id=9360002} and post the question correctly with all the mentioned points in the thread. It facilitates the people to understand the problem clearly and provide a solution that is compatible with your Oracle Version.

  • AL11 - Can't display all data in a file

    Hello,
    We have a custom folder at OS level and configured in the AL11. We are able to open the custom folder and browse all the files. We have a file of 8 KB in size and has around 21 fields. When we open the file in AL11, it doesn't display all the data, that is couple of fields from end. The physical file shows all data and looks fine.
    Anybody can help finding the problem?
    Appreciate your help
    Thanks,
    Kris

    Hi,
    I thing this is authorisation or permission issue pls chek in super user like sap* or equal of this.
    Anil

  • How to display all data on one page in web app

    Hello.
    So I have web app JSF (IceFaces framework) + JBoss all Crystal Report working perfectly. So I have page with Crystal Report tags (e.g.
    <bocrv:reportPageViewer reportSource="#{crystalReport.reportPath}" ...
    in this report I have table with some data (data from DB) and I want to display this data on one page. Unfortunately now this data are moving to the next page and unfortunately I even donu2019t know how switch to the next page (I see only info e.g. 1with 2).
    So how to display this data on one page if its impossible how to torn on pagination.

    So I canu2019t do this, I canu2019t display all data on one page (until Iu2019m using JSF tags)?
    In JSF tags Iu2019m setting only path to file. In my bean Iu2019m using u201CReportClientDocumentu201D object itu2019s easy way to load report file (u201Copenu201D method) and set parameters (u201CgetDataDefController().getParameterFieldController()u201D method) and also connect to data base (u201Clogonu201D method) but I havenu2019t this property u201CsetSeparatePages(boolean)u201D.
    Maybe Iu2019m doing this wrong and there is a simpler way maybe I can use somehow u201CCrystalReportVieweru201D please give my any advice.

  • SSAS Date Dimension attribute not displaying all members when browsed singly

    I have an SSAS Cube database that holds data from 2009 to 2013 (5 years)
    There is a Date Dimension in the database which holds a "Calender Period" Hierarchy with the attributes CalenderYear >> Quarter >> MonthYear >> Day .
    I am connecting to the cube via Microsot EXCEL
    Whenever i try to browse this hierarchy alone in the spread sheet, the first attribute as per the hierarchy shown above i.e. Calender Year does not display all the members, that is confusing the users to assume that the cube is not processed with the latest
    data, which is not the case. However as soon as i try to browse any measure with this dimension, the data automatically shows for the latest dates of 2013 as per the expectations.
    The perspective that is selected while connecting to the Cube in this case is the one that is by default the one including all the Cube Objects.
    Whenever i try to browse the same cube for the same Dimension Hierarchy but in a separate user perspective i get the latest three Calender Years i.e. 2011,2012 and 2013 but not the complete years 2009 to 2013.
    When i was browsing this earlier by the original base perspective (which has all the cube objects visible) the Calender Years displayed were 2009,2010,2011&2012 but not 2013 which should be there.
    I checked the base view in the DB that is used to create this Dimension, that is fetching the complete data for 2009 to 2013.
    I have also verified that this issue is still there if i try to browse the cube from the SSMS.
    Can anyone help me to get all the years from 2009 to 2013 (the years for which my cube has data) become visible as soon as i drop it alone into the Spreadsheet?
    Thanks 
    Suvrat

    Thanks for your response Muthukumaran.
    I did not know about this default measure property of the SSAS cube, it would be nice if you could also tell me how to check which is the default measure for a cube.
    I understand your point that if a particular measure group does not have data for a year then that particular year will be skipped as per the default excel settings, which when disabled allowed all the years to be displayed, but in that case every time the
    users connect to the cube via excel, they will have to configure this property.
    I would like to share the way i resolved this issue:
    I went ahead and simply did a Process Full for the Date dimension. The years started to display by default as per the expectations. Now after observing this change, as per my understanding I believe this issue was due to the CACHE of the cube not being updated
    for the date dimension. As after each incremental load of the DWH we processed the cube & while processing the cube the dimensions were set for a Process Update and the Measure Groups were set for a Process Full. This caused this issue, and we could resolve
    this once the Date Dimension was processed full.
    Thanks
    Suvrat Rai

  • Can I use dates from dual to fetch all he rows between that dates?

    I am trying to get the records that have expirations in the month of May
    What is the correct syntax to use the dates from dual to get all the rows that fall between two dates.
    I am stuck with this query..
    can any one look into it please..
    insert into RENEWALS_ALL_MAY
    select
    from
    ORIGINAL
    where
    (expiration_date between to_date(trunc(add_months (sysdate,3),'mm') from dual) and to_date(last_day(add_months (sysdate,3)) from dual))

    SQL Reference
    Supplied PL/SQL Packages and Types Reference
    For Oracle 9.2
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/functions2a.htm#80856
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/toc.htm
    For other versions see
    http://tahiti.oracle.com/

  • Problem while displaying all the table names from a MS Access Data Source.

    I started preparing a small Database application. I want to display all the Table Names which are in the 'MS Access' Data Source.
    I started to executing by "Select * from Tab" as if in SQL.
    But i got an error saying that "Not able to resolve Symbol 'Tab' in the query".
    Please let me know how can i display all the table Names in the MS Access Dats Source.

    Here i am developing the application in Swing using JDBC for accessing the database.
    I want to display all the Table names from the data source in a ListBox for easy selection of tables to view their details.

Maybe you are looking for

  • How to pass internal table to form routine..?

    Gurus, I am creating a custom Function module in which i have declared few perform statements and passing internal table to it..but when i declare the form it gives me error that the internal table is unknown...Can u please suggest me what am i doing

  • Adobe Acrobat Pro Extended: CSV Export of a 3D-Model doesn´t work

    Hello @ all. I´m using the Adobe Acrobat 9 Pro Extended Tool. Now I want to export a 3D Model in a csv-file. I´ts no problem to export it in a xml-file andnopen it, but if I want to open the exported csv-file, then I see nothing -> an empty excel tab

  • Illiustrator 9.0 won't upgrade to 9.01

    I get this message: ":The file on your system does not match the original Adobe Illustrator file 9.0 expected ... " What's going on? It's the same computer. Thanks.

  • Cost capturing when issue spares from Maintenance Store

    Hi Guru's, I have a scenario which is typical and applicable to most of the factories. Maintenance planner raise the PR and once the material has come to store . Immediately they will take it from store through maintenance order. So that they dont wa

  • Any good way to sort an ArrayList??

    I have a ArrayList now which must be sorted by the order such as: All string message number float My arrayList may only contains some of them, lets say{"float","string","number"}. how can I make this sort? thanks for any advice.