Range Date to Individual date.

Hi Legends,
I have one requirement. I have done it through PL/ SQL but it's taking too long to process that. Can you please suggest whether this can be done through SQL only?
Table:
CREATE TABLE test_lonely
  ( db_id NUMBER, start_date DATE, end_date DATE
  );*1st Requirement:*
Data Set 1:
insert into test_lonely values ( 1, '01-JAN-2013', '03-JAN-2013');This should be changed to
1, '01-JAN-2013'
1,'02-JAN-2013'
1,'03-JAN-2013'*2nd Requirement:*
Data Set 2:
insert into test_lonely values ( 1, '01-JAN-2013', null);This should be changed to
1, '01-JAN-2013'*3rd Requirement:*
Data Set 3:
insert into test_lonely values ( 1, null, '04-JAN-2013');This should be changed to
1, '04-JAN-2013'*4th Requirement:*
Data Set 3:
insert into test_lonely values ( 1, null,null);This should be changed to
1, nullHope my requirement is clear.
added tag properly :D                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Hi,
Here's one way:
WITH   got_n_times     AS
     SELECT     db_id, start_date, end_date
     ,     CASE
              WHEN  LEAST    (start_date, end_date) IS NOT NULL
              THEN  GREATEST (start_date, end_date)
                        + 1
                  - LEAST        (start_date, end_date)
              ELSE  1
          END     AS n_times
     FROM    test_lonely
,     got_max_n_times     AS
     SELECT  MAX (n_times)     AS max_n_times
     FROM     got_n_times
,     cntr          AS
     SELECT     LEVEL     AS n
     FROM     got_max_n_times
     CONNECT BY     LEVEL     <= max_n_times
SELECT       t.db_id
,       CASE
           WHEN  c.n = 1
           THEN  NVL (t.start_date, t.end_date)
           ELSE  LEAST (t.start_date, t.end_date) + c.n
                                                - 1
       END     AS a_date
FROM       got_n_times  t
JOIN       cntr            c  ON  c.n <= t.n_times
;Most of the complexity is needed only to handle multiple rows.
The query abpve does produces N rows when start_date is N days after end_date. That's easy to change if you want only 1 row of output in that case.

Similar Messages

  • Retrieve specific range data from oracle table

    Hi, Dear friends,
    I want to retrieve all the data from oracle table and then save them to mysql table using JDBC ResultSet. The problem is that some oracle table is too big, if I retrieve all of them to memory at a once time using excuteQuery, the program will become no response out of memory limitation. So my question is if I can retrieve just specific range data once a time. I can¡¯t find this function through JDBC API. Also, I don¡¯t want to use the specific sql sentence, for example ¡°select ¡ from¡ where someid>¡ and someid<¡¡±, because there are many different tables, I want to transfer them automatically. So I can¡¯t construct such sql sentence in advance. Does anyone know if oracle JDBC driver provide such kind of function or does there any other way?
    Any suggestion will be greatly appreciated!
    Sammy

    Dear Justin,
    thank you so much for your prompt reply!
    as your suggestion, I do check the performance while my program is running, after the program become nearly no response, I found the memory usage is nearly 100%, while disk usage and process usage is pretty low. that's the reason why I guess maybe the memory limitation, but the strange thing is that no any error reported by JBuilder, it just nearly no response and don't transfer any data any more. my os is windows xp, the version of JBuilder is 7. my main memory is 768M. just as you said, the total 6,000 records in not very large, just no more than 400K. another strange thing is that why my program works well when there is little data records in the table.
    the big picture of my program is first I retrieve oracle table metadata, according to this information, I construct DDL sql words and then create the corresponding table in mysql database. this part works well. in order to save your time, I will not paste the code here. then there is a method to transfer oracle data to mysql table, whenever creating the mysql table, then I will call this method to transfer datat to it. the following is the code of this method, I am very sorry to take your time. please read it when you are available.
    thank you very much!!
    Sammy
    //transfer data from oracle to mysql!!!
    private static void transferData(Connection oracleConn, Connection mysqlConn, String oracleTableName, String oracleSchemaName) throws SQLException{
    Statement oracleStmt=oracleConn.createStatement();
    Statement mysqlStmt=mysqlConn.createStatement();
    // sending sql to oracle to retrieve data
    String thisTableName=oracleTableName;
    String oracleSQL="SELECT * FROM ".concat(thisTableName);
    ResultSet oracleRS = oracleStmt.executeQuery(oracleSQL);
    String sql="";
    if (oracleRS.next()) {
    ResultSetMetaData rsmd = oracleRS.getMetaData();
    int colCount = rsmd.getColumnCount();
    do {
    String sqlBodyPart="";
    String sqlValuePart="";
    System.out.println("the number of column is "+colCount);
    for (int i = 1; i <= colCount; i++) {
    String columnValue = oracleRS.getString(i);
    boolean b = oracleRS.wasNull();
    String columnName =rsmd.getColumnName(i);
    System.out.println("the value of column " + i + "is " + columnValue);
    //construc the sql body part and value part
    sqlBodyPart=sqlBodyPart.concat(" ").concat(columnName).concat(",");
    if(b){ //if the value of the column i is null
    sqlValuePart=sqlValuePart.concat(" null").concat(",");
    }else{
    sqlValuePart=sqlValuePart.concat(" '").concat(columnValue).concat("',");
    //get rid of the last comma in sqlBodyPart and sqlValuePart
    if(!sqlBodyPart.equalsIgnoreCase("")) sqlBodyPart=sqlBodyPart.substring(0,sqlBodyPart.length()-1);
    if(!sqlValuePart.equalsIgnoreCase("")) sqlValuePart=sqlValuePart.substring(0,sqlValuePart.length()-1);
    //construct the sql sentence!!!
    sql="INSERT INTO ".concat(thisTableName).concat(" (").concat(sqlBodyPart).concat(") ").concat(" VALUES(").concat(sqlValuePart).concat(")");
    System.out.println("the sql words for this column is");
    System.out.println(sql);
    System.out.println(" ");
    if(mysqlStmt!=null){
    int rows = mysqlStmt.executeUpdate(sql);
    } else{
    System.out.println("can't connect with mysql server");
    System.exit(1);
    while (oracleRS.next());
    } else {
    System.out.println("There are no data in the table...");
    }//end of method data transfer!
    //end of method data transfer!

  • Partiton by range date field

    I am creating a script that will automatically create the partitions. My partition key is a Date field
    I am testing changing date field uing Date, Timestamp and Timestamp with local time zone.
    How should my values less than clause look for Timestamp and
    Timestamp with local time zone?
    For example, testing for date looks like this:
    Partition 2005_JAN values less than (to_date('2005-02-01 00:00:00',SYYYY-MM-DD HH24:MI:SS') tablespace data01;

    Mike,
    if I understand your task right, you would like to have a script which would automatically create new partition for every new month/year.
    You can use something like that using EXECUTE IMMEDIATE and dynamic
    SQL to create new partition:
    SQL> create table t (date# date)
      2  partition by range(date#)
      3  (PARTITION DATES_AUG VALUES LESS THAN (TO_DATE('01-09-2005','DD-MM-YYYY')));
    Table created.
    SQL> select table_name, partition_name from user_tab_partitions
      2  where table_name = 'T';
    TABLE_NAME                     PARTITION_NAME
    T                              DATES_AUG
    SQL> declare
      2   cnt number(1);
      3  begin
      4 
      5   select count(1) into cnt from user_tab_partitions
      6   where table_name = 'T' and partition_name = 'DATES_' ||
      7   to_char(last_day(sysdate)+1,'MON');
      8 
      9   if cnt = 1 then return; end if;
    10 
    11   execute immediate 'ALTER TABLE t ADD PARTITION DATES_'
    12   || to_char(last_day(sysdate)+1,'MON') ||
    13   ' VALUES LESS THAN (TO_DATE(''' || to_char(last_day(sysdate)+1,'DD-MM-YYYY') || ''''
    14   || ',' || '''DD-MM-YYYY''))';
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    SQL> select table_name, partition_name from user_tab_partitions
      2  where table_name = 'T';
    TABLE_NAME                     PARTITION_NAME
    T                              DATES_AUG
    T                              DATES_OCTTo be franky this is hardly relevant forum to ask this sort or questions, it would be better to ask it in SQL-PL/SQL or Database General ones.
    Rgds.

  • Filter Data with Date range.Dates are selected in user form

    Does anybody could help me to create a user form, that user could select the date and time from either calendar or other control button (from Userform control Toolbox) and the VBA code would filter the data on Excel SpreadSheet depending on input...
    I want user to specify start time and the end time, that I would know the period of time which is on interest and filter the data depending on inputs...
    This is part of my table on Sheet1:
    ID                     Time
      Products
    ProdNoExit
    8
    04-06-2013 23:00
    15
    1
    8
    04-06-2013 23:30
    205
    1
    8
    05-06-2013 00:00
    235
    1
    8
    05-06-2013 00:30
    587
    1
    8
    05-06-2013 01:00
    874
    1
    8
    05-06-2013 01:30
    155
    1
    8
    05-06-2013 02:00
    150
    1
    8
    05-06-2013 02:30
    258
    1

    How about this?
    Right-click your tab name, and paste this code into the window that opens.
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Address = "$A$1" Or _
    Target.Address = "$G$1" Then
    Range("Database").AdvancedFilter _
    Action:=xlFilterInPlace, _
    CriteriaRange:=Range("Criteria"), Unique:=False
    End If
    End Sub
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

  • Function Module required for getting Value Range data

    I need a function module where in i can get the data from a value range in a domain.
    Message was edited by:
            Gurpreet Singh

    Hi,
    You can use this code to get the Doman's fixed values.
    DATA:  lt_fixed_values     TYPE ddfixvalues,
      CALL METHOD cl_abap_typedescr=>describe_by_name
        EXPORTING
          p_data      = 'Domain_name' " Pass the domain name here
        RECEIVING
          p_descr_ref = lcl_abap_typedescr.
      TRY.
          lcl_abap_elemdescr ?= lcl_abap_typedescr.
        CATCH cx_sy_move_cast_error.
      ENDTRY.
      IF lcl_abap_elemdescr IS BOUND.
        CALL METHOD lcl_abap_elemdescr->get_ddic_fixed_values
          EXPORTING
            p_langu        = sy-langu " Give the language
          RECEIVING
            p_fixed_values = lt_fixed_values " This table will have the fixed values
          EXCEPTIONS
            not_found      = 1
            no_ddic_type   = 2
            OTHERS         = 3.
      ENDIF.
    Regards,
    Sesh

  • Accessing datetime  range data from table...

    Hey Everyone,
    I have table called vdet_sa_archive and in that table there are so many fields and i want to access the data on datetime range.
    sample data in table
    starttime endtime
    1 14-02-13 01:30:15.000000000 AM 14-02-13 02:01:57.000000000 AM
    2 14-02-13 4:30:01.000000000 AM 14-02-13 5:30:01.000000000 AM
    3 14-02-13 01:30:01.000000000 PM 14-02-13 01:45:01.000000000 PM
    So i want to access the data between 14-02-13 1:00:00 AM to 14-02-13 5:00:00 AM
    So how can i get this data
    i wrote like
    select count(*) from vdet_sa_archive where starttime >= TO_DATE('14/FEB/2013 01:00:00 AM', 'dd/mm/yyyy HH:MI:SS AM') and endtime<=TO_DATE('14/FEB/2013 04:00:00 AM', 'dd/mm/yyyy HH:MI:SS AM');
    But its not working.
    Thanks and regards,
    Gajanan Hiroji

    Hi, Gajanan,
    Gajananh999 wrote:
    Hey Everyone,
    I have table called vdet_sa_archive and in that table there are so many fields and i want to access the data on datetime range.
    sample data in table
    starttime endtime
    1 14-02-13 01:30:15.000000000 AM 14-02-13 02:01:57.000000000 AM
    2 14-02-13 4:30:01.000000000 AM 14-02-13 5:30:01.000000000 AM
    3 14-02-13 01:30:01.000000000 PM 14-02-13 01:45:01.000000000 PMWhenever you have a problem, post CREATE TABLE and INSERT statements for you sample data. This problem may hinge on what the data types of starttime and endtime are.
    So i want to access the data between 14-02-13 1:00:00 AM to 14-02-13 5:00:00 AMIn the code below, the upper bound is 4:00 AM, not 5:00.
    So how can i get this data
    i wrote like
    select count(*) from vdet_sa_archive where starttime >= TO_DATE('14/FEB/2013 01:00:00 AM', 'dd/mm/yyyy HH:MI:SS AM') and endtime<=TO_DATE('14/FEB/2013 04:00:00 AM', 'dd/mm/yyyy HH:MI:SS AM');
    But its not working.What exactly is not working? When you post the CREATE TABLE and INSERT statements for the sample data, also post the results you want from that data.
    As mentioned before, if you're using 'MM' format, the month is '02'. If you use 'MON' format, then 'FEB' means February, assuming your NLS_DATE_LANGUAGE is English.
    If startdate and enddate are TIMESTAMPs (which is what it looks like) then it would be more efficient to use TO_<b>TIMESTAMP</b> rather than TO_<b>DATE</b> , but you should get the same results either way, unless perhaps if a value was a fraction of a second off from the given range.

  • Using SSRS Date Range- Data Not shown for date greater than by Analysis Services

    Hello Friends,
     I am using Date Range filters(Start and End Date) in my SSRS Report. The Problem is that if i am using the start date will be today, then the end date will be the future date by using Analysis Service as my Data Source, the report is not generated.
    I don't know why it happens? If I give the date range filters before the current date, then the report will shown.
    The problem is that the future date is not in my database. Could you please answer for this. I am struck in here,.
    Table contains : 1-7-14 ,
    2-7-14,
    3-7-14,
    If my Date Range will be 1st to 3 of 7th month, then the report shows the data.
    if my date starts with 1st of the 7th month and ends in the future, then the report will not shown the 2nd and 3rd records...
    Please teach me why?

    Your question should be posted to the appropriate MSDN forum.  This forum is for questions regarding Microsoft Certifications.

  • Query using 0calmonth, to input the month range, data incorrect

    hi, experts,
    I have a query using 0CALMONTH in the filter, restricted the range value ( eg. 2009.01-2009.08 ),
    but the data in Bex Analyzer only 2009.08, doest not collect the cube data from 2009.01 to 2009.08.
    If restrict the single value (eg, 2009.02), the data is correct.
    I tried to restrict the key figure by 0CALMONTH and then tried using variables with an offset but it does not work as input is a month range.
    my bw support package13, basis sp12.
    thanks in advance,
    xwu.

    this issue solved by myself, there is a non-cumulative Key Figure.
    thanks,
    xwu.

  • Disable multiple range dates in datechooser/datefield

    Hello guys.
    im wondering if anyone ever came across this problem i know the datechooser/datefield component has the disableRanges method which allows you to bascically send in array with start and end date and disable those days. That works great but what if i want to disable multiple ranges.
    has anyone ever come accross this problem.
    i have a field like so
    <mx:DateField x="101" y="6"  id="startDateInput"    change="datefield2_changeHandler(event)"/>
    and in actions ript i do something like this.
    startDateInput.disabledRanges = ([new Date(),{rangeStart: new Date(startDateInput.selectedDate.fullYear,startDateInput.selectedDate.month,startDateInput.selectedDate.date), rangeEnd: new Date(endDateInput.selectedDate.fullYear, endDateInput.selectedDate.month, endDateInput.selectedDate.date)}]);
    So i have try adding more rangeStart and more rangeEnd to disable more days but nothing works???
    any ideas I could really use some help?
    thanks in advance
    Miguel

    thats correct so say i would like to disable
    5-10
    and
    20-25
    and leave the rest still light up.
    Do you have a small example you can share. I would be forever greatful. I've been knocking my head on this for a few days now. I even consider building a custom calendar.
    really appreciate the response.
    Miguel

  • Calendar range data

    Hi All,
    my requrement is i want to display the data betwenn 2 calendar date rage
    I mean
    I have 25 rows for each day with 4 columns like
    StartDate  End Date     Tcode    Count
    01/01/09   01/01/09     rsa1      300
    01/01/09   01/01/09     rsa2       400
    02/01/09   02/01/09     rsa2       400
    I would like select start date in the first calendar and end date in the next calendar
    then it suppose to display tcode Vs Count as column chart.
    I am getting data from WebI to Live Office and then imorting into the xcelsius.
    Thanks
    Muvva

    As you are getting data from WEBI --> Live Office. I think you can modify the webi query and add 2 prompts i.e. StartDate and EndDate in the Filters panel in Query Designer.
    In Excel, have 2 cells one which will hold StartDate that user selects in the Calender and other for EndDate.

  • Color space, gamma, and code value range data

    Greetings!
    I'm getting close to submitting my film for professional DCP creation.  It's a ProRes 422 4096 by 1716, 2.39 - 1 file, created as a "master file" in a Premiere Pro CC export (the sequence being an "online" of sorts, built from SpeedGrade color-corrected DPX files).
    The Guidelines for "Digital Cinema Source Delivery" require me to provide information about Color Space, Gamma, and Code Value Range Information (head vs full).  Specifically, an order form asks for TRT, Color-Space, and Full or Head. 
    This is simply all Greek to me.  I know my film looks gorgeous, and the rest of what I've told you, but that's the limit of my experience.
    Can someone help me out?  Specifics are preferred to broad strokes.  Many thanks in advance.

    This is probably too late now for you anyway but here is some extra information:
    The "Digital Source Master" is the video footage before any D-Cinema formatting or encoding has been done.
    It can be literally anything. The DCI specification did not specify this.
    They did however specify exactly what the transcoded verison has to look like. The "D-Cinema Distribution Master" (16bit TIFF, XYZ)
    So in other words, you need to tell your service provider:
    The resolution, fileformat, frame rate and especially the colourspace that you used.
    For example r709 for HD or any other RGB colourspace with applied gamma value (2.3 for example).

  • How to display null values in the graphs, when i select a date range?

    Hi,
    Can you please help me in achieving the below requirement:
    We have a date promt, i have selected the date range from 12-Oct-2009 to 15-Oct-2009 and clicked on the go button.
    In the above date range, data is only availabe on 14-Oct-2009. here the requirement is to display as all the records (12th, 13th , 14th & 15th) in the bar graph.
    Currently the graph view is displaying the data only for 14-Oct-2009 in the bar graph.
    If data is not available it should display in the bar graph as empty for that particular dates.
    Help is highly apprieciated.
    Thanks in Advance.

    Check out [this post|http://obiee101.blogspot.com/2009/04/obiee-showing-zero-in-bargraph.html].

  • How to select range for dater in BAPI_DOCUMENT_GETLIST2

    Hi All
    I have following problem with this FM BAPI_DOCUMENT_GETLIST2. I was looking a lot on different forums but I cannot find answer which corresponds to my problem.
    I have in DMS saved files for our customer and Iu2019m using object linking as
    Objlinkselection-DOKOB  =  KNA1
    Objlinkselection- OBJKY   = KUNNR.
    It works well, but it takes all doc from beginning.  Iu2019d like to make selection that final table documentdata is in range of defined range date with values 20111201 to 20111231
    Now I have to select all documents for this customer and after that I have to make loop to get correct files. And it takes a huge time and in a few years it will collaps
    LOOP AT LT_DOCUMENTDATA INTO <FS> WHERE CREATEDATE IN  rn_DATE.
    ENDLOOP.
    Any hint how to make this faster? 
    Just to avoid any misunderstandings, I'm not asking on loop speed but how to select by FM less rows based on create date.
    Thank a lot fo any hint
    Petr

    Hello Deepak,
    Thanks a lot for your answer. I have read this thread already, but it is not realy what I need. But anyway in the night I have found solution.
    I will go through table DRAW where I will get just DOCNUMS for current date range.
    Than I will select correct rows from table DRAD for selected KUNNR.
    Final set od DOCNUMS I will use as selection criteria for BAPI.
    It should help, now I go to try it.
    Thansk anyway
    Petr

  • Regarding date ranges in search criteria in oracle forms

    I am using employee number,name, person type, and date ranges as search criteria in custom form.
    when I enter employee number, hit the find button, I am getting the exact info in the result block.
    Result block contains
    employee name,personid,emp numb,org,start_date.
    Similarly when I enter employee number,dept, I am getting correct values.
    My question here is, when I enter date range. Iam unable to filter data.
    When i enter START_DATE between nvl(:BLOCKNAME.START_DATE,'01-JAN-1901') and nvl(:BLOCKNAME.END_DATE,'31-DEC-4712') at where clause in the result block. I got data for the date range also.
    if I give condition in the where clause, results are taking so much time when i search with employee name,number,dept,person type.
    If i query with date, persormance is good.
    Do u any know,how to prevent START_DATE between nvl(:BLOCKNAME.START_DATE,'01-JAN-1901') and nvl(:BLOCKNAME.END_DATE,'31-DEC-4712') when we search with employee name,number,dept,person type.

    Initailly Ididnt given any code in the where clause of the result block. I got data in the result block when i search with employee name,number,person type,dept etc except date range.
    If i give date range, irrespective of the date, getting all the data.
    after that i added code to the where clause of the result block. Now i am getting data for everything.
    like, when i query with employee name,number,even date range also.
    My question here, performance.
    when I query with date range, data is coming in expected time in the result block.
    when i query with dept, taking much time since date range logic exist in the where clause of the result block.
    I need to restrict the where clause only to the data ranges. Where clause should not necessary for employee number,name,person type dept search criteria
    Tahnks for your reply

  • Reg caluclating date range?

    hi friends
    my requirement is i have to retrive data based on the one month date range given on the date in my selection screen . how to caluclate one month range for the given date ? is there any function module available ? can i use hr function modules in abap ?
    thanks & regards
    deepurd

    First You told this;
    >
    deepu rd wrote:
    >actually my requirement is i have to retrieve the data which is entered from the last one month of given date >in selection screen? whatsthe function module for getting this
    >ex: suppose i given 20-11-2008
    >i have to retrieve the data between 20-10-2008 to 20-12-2008
    Now you are telling this;
    >
    deepu rd wrote:
    > hi sravanthi
    >               when i was trying to use the HR function module its giving dump .
    >               my requiremnt is
    >               if selection screen input date is 25-12-2008 i have to retrive documents posted within 1 month range . data between 24-11-2008 to 25-12-2008.
    >
    > regards
    > deepurd
    Do you know that thus you are effectively wasting yours as well as others time?
    Can't you use the above codings and FM's given by all to achieve your requirement.
    First of all you come to a conclusion on what you want, then you can arrive at the solution using all the above inputs and ideas.
    Regards
    Karthik D

Maybe you are looking for