Range query date day 1 to day 1-14 years

I use:

Oracle SQL Developer (3.0.04)

Build hand - 04.34

Oracle Database 11g

Enterprise Edition 11.2.0.1.0 - 64 bit Production

I'll have time to diffitult get this filter works:

{Code}

where date_value between: day1 and: day 1-14

{Code}

What I am doing wrong?

I am looking for a single day of entry and have it return a range of 14 days. So if I put "June 25, 2013", it must understand that day and the 14 day return track.

Hello

When you say "BETWEEN x AND y", x must be the smallest value.

You need something like:

WHERE the date_value BETWEEN day 1 - 14 AND day 1

This assumes that the date_value and day1 are DATEs.  There is no variable binding DATE.  "If: day 1 is a string, such as June 25, 2013", then use TO_DATE to get a DATE based on this string:

WHERE the date_value BETWEEN TO_DATE (: day1, "MON-DD-YYYY")-14

AND TO_DATE (: day1, 'DD-MON-YYYY')

Tags: Database

Similar Questions

  • Report with 2 settings of filtering by day and 3 measures for a range of dates

    Hello

    I need to establish a relationship with the following criteria:

    (a) I have 5 settings

    (b) tell of 2 measures of data should be based on a date 01/01/2015

    (c) rest of 3 data measures should be based on a range of dates say 01/01/2015-31/01/2015

    No idea how to achieve this?  If so please help me.

    Thanks in advance

    LonaD

    You cannot filter the reports by using the filter function in the formula in the column?

  • split with day, month and year in a date

    Hi all

    I have this point of view

    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    --
    -end of test data
    --
    SELECT id, dt
    floor (months_between(sysdate,dt)/12) years
    , floor (mod (months_between (sysdate, dt), 12)) months
    -The day is ambiguous because of the number of days in a different month
    -you could design your own algorithm to give the desired results, but it is a good approximation
    , floor (sysdate-(add_months (dt, floor (months_between (sysdate, dt))) as dys
    t
    /
    ID DT YEARS MONTHS DYS
    ---------- ----------- ---------- ---------- ----------
    1-6 FEBRUARY 2010 5 8 22
    2 29 NOVEMBER 2001 13 10 29
    3-6 FEBRUARY 2011 4 8 22
    4-10 OCTOBER 2011 4 0 18

    As a result, 26 years old, 26 months, 91 days.


    And subtract years, MONTHS and DYS as format

    erase years, from 1 to 12 months and the days of the 1 to 30 as

    91 days = 30 x 3 + 1 = > 1 day over 3 months

    26 months + 3 months = 29 months = > 24 months + 5 months = 2 years + 5 months

    and 26 years + 2 years = 28

    desire to result: 28 years, 5 months and 1 day.

    Is there a function that give me this result from the query above?

    Kind regards

    Gordan

    Hello Gordan,.

    I understand that you are the SUM of all the lines.

    Here are two ideas:

    -1 - using a date
    (a) SUM (TRUNC (sysdate) - dt)
    I would give you the total number of days.
    (b) adding the number of days to, for example, DATE ' 1900-01-01' would give another date...
    (c) simply subtract the years 1900 and it takes several years,
    subtract 1 from the month (1-12 from January to December) and you have the number of months
    subtract 1 from the day of the month (1-31) and you have the number of days.
    It is of course 'approximate' as the months do not have the same number of days...

    -2 - using only the number of days
    Maybe you want something else, for example: the total number of days divided by 365.25 for many years, the recall divided by 30 to get the number of months, the reminder being the number of days.

    (a) SUM (TRUNC (sysdate) - dt)

    I would give you the total number of days.

    (b) Division by 365.25 (le.25 is to take leap years into account, but you can choose for example "365")

    (c) number of reminder of days (total - years * 365.25): divided by 30 is the number of months

    (d) number reminder of days (total - years * 365.25 - months * 30): gives the number of days.

    The following two options with your test data (by chance, this gives the same result in this case)

    option 1:
    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    target_date AS
    (SELECT DATE ' 1900-01-01' + SUM (TRUNC (sysdate) - t.dt) FROM t trgt)
    in_pieces AS
    (SELECT TO_NUMBER (TO_CHAR (td.trgt, 'YYYY')) - 1900 y
    , TO_NUMBER (TO_CHAR (td.trgt, 'MM')) - 1 m
    , TO_NUMBER (TO_CHAR (td.trgt, 'DD')) - 1 d
    Target_date TD
    )
    SELECT "result: ' |"
    TRIM (CASE WHEN ip.y = 0 THEN NULL
    WHEN ip.y = 1 THEN "1 year"
    Of OTHER TO_CHAR (ip.y) | "years".
    END |
    CASE WHEN ip.m = 0 THEN NULL
    WHEN ip.m = 1 THEN "1 month"
    Of OTHER TO_CHAR (ip.m) | 'months '.
    END |
    CASE WHEN ip.d = 0 THEN NULL
    WHEN ip.d = 1 THEN "1 day"
    Of OTHER TO_CHAR (ip.d) | 'days '.
    END
    )
    Of in_pieces ip
    ;
    result: 28 years, 4 months and 28 days

    option 2:

    with (id, dt) t (select 1, to_date('02/06/2010','MM/DD/YYYY') of all the double union)
    Select 2, to_date('11/29/2001','MM/DD/YYYY') of all the double union
    Select 3, to_date('02/06/2011','MM/DD/YYYY') of all the double union
    Select option 4, double to_date('10/10/2011','MM/DD/YYYY')
    )
    nb_days AS
    (SELECT SUM (TRUNC (sysdate) - t.dt) n t)
    , y AS
    (SELECT Nb.n, FLOOR (nb.n / 365.25) y nb_days n. b.)
    ym AS
    (SELECT y.n, y.y, FLOOR ((y.n-y.y * 365,25) / 30) FROM a)
    ymd AS
    (SELECT ym.y, ym.m, ym.n - ym.y * 365.25 - ym.m * ym FROM 30 d)
    SELECT "result: ' |"
    TRIM (CASE WHEN ymd.y = 0 THEN NULL
    WHEN ymd.y = 1 THEN "1 year"
    Of OTHER TO_CHAR (ymd.y) | "years".
    END |
    CASE WHEN ymd.m = 0 THEN NULL
    WHEN ymd.m = 1 THEN "1 month"
    Of OTHER TO_CHAR (ymd.m) | 'months '.
    END |
    CASE WHEN ymd.d = 0 THEN NULL
    WHEN ymd.d = 1 THEN "1 day"
    Of OTHER TO_CHAR (ymd.d) | 'days '.
    END
    )
    WAN
    ;
    result: 28 years, 4 months and 28 days

    Best regards

    Bruno Vroman.

  • conclusion date, day of the month all

    Dear members,

    find the date, day of a specific month in a query. Is there a default, or built-in feature.

    for example to select date, day
    Of...
    where month = "JAN";

    date day
    01/01/2011 Sunday
    01/02/2011 Monday
    .
    .
    .
    .
    31/01/2011 Tuesday



    Thank you.


    teefu.

    I have to show the rest of the dates of the month January too

    You can do an outer join partioned too, using for example the emp table:

    SQL> with dates as (
      2   select date '1981-02-01' + level - 1 days from dual connect by level <= 28
      3  )
      4  --
      5  --
      6  select to_char(days, 'dd-mm-yyyy day') months_day, ename, hiredate
      7    from dates partition by (trunc (hiredate, 'dd'))
      8         left outer join emp
      9         on (trunc (hiredate, 'dd') = trunc (days, 'dd'))
     10         order by days
     11  /
    
    MONTHS_DAY           ENAME      HIREDATE
    -------------------- ---------- -------------------
    01-02-1981 sunday
    02-02-1981 monday
    03-02-1981 tuesday
    04-02-1981 wednesday
    05-02-1981 thursday
    06-02-1981 friday
    07-02-1981 saturday
    08-02-1981 sunday
    09-02-1981 monday
    10-02-1981 tuesday
    11-02-1981 wednesday
    12-02-1981 thursday
    13-02-1981 friday
    14-02-1981 saturday
    15-02-1981 sunday
    16-02-1981 monday
    17-02-1981 tuesday
    18-02-1981 wednesday
    19-02-1981 thursday
    20-02-1981 friday    ALLEN      20/02/1981 00:00:00
    21-02-1981 saturday
    22-02-1981 sunday    WARD       22/02/1981 00:00:00
    23-02-1981 monday
    24-02-1981 tuesday
    25-02-1981 wednesday
    26-02-1981 thursday
    27-02-1981 friday
    28-02-1981 saturday
    
    28 rows selected.
    
    SQL>
    SQL>
    SQL>
    
  • How to read the date of the day of the day of the year?

    I want to put 30 days for the test of endurance for the application of the components. the user will have the current value of 30 days with specify them the end of the day.

    I saw that the "seconds to Date/Time.vi" sure I checked the day of the year. If I can use this day of the year, I can add + 30 read 30 date.

    Barros,

    What I gave was the answer you were looking for originally because I believe.  You will not just be able to read the date in a coherent way and then add 30.  You can either use the function Get time in seconds or a few varaint it and then add the offset you want (you could use the get a Date/time string and enter the date directly, but this digital conversion which will be useful in the monitoring of the time elapsed will be much more difficult than what I provided only).  If you want to stop the test, simply to keep track of the amount of time the test is in pause and extension at the time where that amount.

    Cheers, Matt

  • The date system in the taskbar indicates the year, month, day (as in the army). How can I read the day, month, year?

    The date system in the taskbar indicates the year, month, day (as in the army). How can I read the day, month, year?

    It's weird, in my version (Windows 7 Pro), it shows much more than that.

  • date - day 1

    Hello

    Currently I use the code below for the date:

    var f = this.getField ("Text29");

    f.Value = util.printd ("dd.mm.yyyy", new Date());

    I want to edit this code, so date would be the new Date - day 1... so if today is 24.5 I want to show 23.5

    Thanks for help

    Look in the JavaScript console.

    Var letter = new Date(); get date system as a date object.

    Console.println ("date system:" + letter); display the date system;

    adjust the date-1 day object;

    oDate.setDate (oDate.getDate () - 1);

    Console.println ("system date - day 1:" + letter);

    this.getField("Text29").value = util.printd ("dd.mm.yyyy", anyway); Set the value of the field;

  • calculate the day of the year using the date.

    Hi all
    Can calculate us the day of the year using the date form? Is this possible? Please help me thanks in advance
    Like this
    30/08/2009-30/08/2010 after calculation - 365


    Sarah

    Published by: SarahSarahSarah on August 30, 2009 12:49 AM

    Sarah.

    : ins1.noday must be a part of number!

    Create a function in forms like this:

    function get_nodays ( f_dtm_start in date,
                          f_dtm_end   in date ) return number is
    begin
    if
      f_dtm_start is null OR
      f_dtm_end is null
    then
      return ( null );
    end if;
    return ( trunc ( f_dtm_start ) - trunc ( f_dtm_end ) );
    exception when others
    then message ( sqlerrm || ' in function get_nodays occured.' );
    return ( null );
    end;
    

    Call this function in the when-validate-point triggers on ins1. INSPERIOD and: ins1.end love

    :ins1.noday := get_nodays ( :ins1.INSPERIOD, :ins1.end );
    

    It is redundant to have the: noday as a cause of part of database
    the value may by calculated every time using the values INSPERIOD and: end.

  • How to filter for a range of dates calendar events in OS10

    In earlier versions of BlackBerry, I used blackberry.find.FilterExpression to filter the events calendar for a specific range of dates.

    However for BlackBerry OS10 I scoured the web to find a way to do it. I found:http://developer.blackberry.com/html5/apis/blackberry.pim.calendar.calendarfindoptions.html

    I also googled a lot of other sites, but I am unable to understand how to use CalendarFindOptions to refine the calendar of events of a specific timetable. For example, the current week or the next 7 days.

    I found this code example...
    Function listEvents (limit) {}
    Calendar var = blackberry.pim.calendar;
      var CalendarFindOptions = calendar. CalendarFindOptions;
      var findOptions = {}
    'Sort': [{}
    "fieldName": CalendarFindOptions.SORT_FIELD_SUMMARY.
    'desc': false
    }],
    'detail': CalendarFindOptions.DETAIL_AGENDA,
    'limit': limit
    };

    But unable to find examples how adequately limited by date?
    I'm guessing that something like this:
    'Start': new Date (' January 1, 2013, 13:00 "): CalendarFindOptions.SORT_FIELD_START.
    'end': new Date (' January 1, 2013, 16:00 "): CalendarFindOptions.SORT_FIELD_STOP.

    But it is an assumption and does not work I can find no example of how do

    Any help would be appreciated

    See the example for pimcalendar on Github:

    https://github.com/BlackBerry/BB10-WebWorks-samples/tree/master/pimcalendar

    You can find the JS to set filters of beginning and end starts here:

    https://github.com/BlackBerry/BB10-WebWorks-samples/BLOB/master/pimcalendar/index.html#L107

  • 1st day of the year then the Monday group

    Hello expert;

    I have the following tables below
    create table table_one
    (
     v_id varchar2(60),
     close_date date
    );
    insert into table_one
      (v_id, close_date)
    values
      ('A', to_date('1/1/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));   --- First day of the year
    
    insert into table_one
      (v_id, close_date)
    values
      ('B', to_date('1/4/2010 2:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));   -- monday
      
      insert into table_one
      (v_id, close_date)
    values
      ('C', to_date('1/11/2010 1:47:19 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  -- monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('D', to_date('5/6/2010 5:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  --- not a monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('E', to_date('5/3/2010 4:47:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  ---monday
      
     insert into table_one
      (v_id, close_date)
    values
      ('F', to_date('2/9/2010 5:17:09 PM', 'MM/DD/YYYY HH:MI:SS:AM'));  -- not monday
    I need to modify my query below and I can't think of a good way to go about it
    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD') from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    group by t.v_id, to_char(t.close_date, 'YYYY-MM-DD');  
      
    what I'm trying to do is in fact I want to group by only Mondays









    Edited by: user13328581 on Nov 17, 2010 8:04 AM
    
    Edited by: user13328581 on Nov 17, 2010 8:04 AM
    
    Edited by: user13328581 on Nov 17, 2010 8:29 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03
    

    If you also want the first day of the year that you mentioned.

    select t.v_id, to_char(t.close_date, 'YYYY-MM-DD')
      from table_one t
    where t.close_date between to_date('2010/1/1', 'YYYY-MM-DD') and to_date('2010/12/31', 'YYYY-MM-DD')
    and   to_char(trunc (t.close_date), 'dy' ) = 'mon'
    or  extract( month from t.close_date) + extract( day from t.close_date) = 2
    
    V_ID     TO_CHAR(T.CLOSE_DATE,'YYYY-MM-DD')
    A     2010-01-01
    B     2010-01-04
    C     2010-01-11
    E     2010-05-03
    

    Published by: pollywog on November 17, 2010 11:38

  • calculate the time in seconds, the day of the year and year

    I have a data file where they record three columns, the seconds elapsed since midnight, day of the year and the year.  I am creating a timestamp of LabVIEW from these three numbers.  Of seconds elapsed since midnight, I can create seconds, minutes and hours.  If I feed in a cluster of time with the day of the year and the year, the timestamp of output is 0.  Does not work.  Although an input of the day of the year element, the Date and time with seconds function apparently requires day for months and months to work.

    The only solution I can imagine at this stage is to calculate the month and the day of the day of the year, which would imply a choice of the month table and a check of the leap year.

    Smart solutions, I'm missing?

    DaveT

    Dave,

    I found a Julian Georgian so far.

  • Set the calendar to display day, month and year

    In addition to the time of day, my computer began giving the day of the week (Monday) only instead of day, month and year as it did before. Tried to go back to 29/12/2014 or something similar without success.  Any suggestions?

    Hello

    Sorry for the late reply and I appreciate your patience.

    User profile corruption might have caused the problem. As a solution, I suggest to create a new user profile and check if the date format displays the same thing.

    To do this, see the link below.

    http://Windows.Microsoft.com/en-us/Windows/fix-corrupted-user-profile#1TC=Windows-7.

    It will be useful. Just answer us with the State, and we will be happy to help you.

  • At least a record exists in details that cover the range of dates

    Oracle version:

    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production

    Hi gurus

    I'm stuck with a scenario and your employees need help to solve this problem.

    I have the following table:

    Insertion and table creation

    drop table ident;

    create table ident

    (

    agreement_id number (5),

    ident_pk number (5),

    Date of Cov_effective_date,

    Date of Cov_termination_date

    );

    -------------------

    Insert ident

    (

    Select 100,1,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-31','YYYY-MM-DD')

    Union of all the

    Select 200,2,to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-12-31','YYYY-MM-DD')

    Union of all the

    Select 300,3, to_date ('2013-03-01 ',' YYYY-MM-DD '), double null

    );

    Query on table

    Select * ident;

    Agreement_id ident_pk Cov_effective_date Cov_termination_date

    100113/01/0113/01/31
    200213/01/0113/12/31
    300313/03/01

    ------------------------

    Drop table ident_dtl;

    create the table ident_dtl

    (

    ident_pk number (5),

    ident_dtl_pk number (5),

    date of effective_date,

    date of termination_date

    );

    ---------------------------------

    insert into ident_dtl

    (

    Select 1-ident_pk, 10 ident_dtl_pk, to_date('2013-01-01','YYYY-MM-DD') effective_date, to_date('2013-01-31','YYYY-MM-DD') termination_date of double - to agreement_id = 100

    Union of all the

    Select 1,11,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - to agreement_id = 100

    Union of all the

    Select 2,12,to_date('2013-01-01','YYYY-MM-DD'), to_date('2013-01-30','YYYY-MM-DD') of double - for agreement_id = 200

    Union of all the

    Select 2.13, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id is 200

    Union of all the

    Select 3.14, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300

    Union of all the

    Select 3.15, to_date('2013-01-01','YYYY-MM-DD'), double to_date('2013-01-15','YYYY-MM-DD') - for agreement_id = 300

    );

    Query on table

    Ident_pk Ident_dtl_pk Effective_date Termination_date

    11013/01/0113/01/31
    11113/01/0113/01/30
    21213/01/0113/01/30
    21313/01/0113/01/15
    31413/01/0113/01/15
    31513/01/0113/01/15


    Result of the will

    Agreement_Id Ident_pk

    200                                        2

    300                                        3

    ------------------------------------

    There is a single entry in ident against agreement_id and Ident_pk and if you can see that ident_pk is also present in the child table. My requirement is that at least 1 effective_date and child termination_date table must be match/equal to the parent table that is ident cov_effective_date and cov_termination_date against the same column of Ident_pk.

    for example:

    See the data in Ident_pk = 1, a = cov_effective_date 13/01/01 and its cov_termination_date = 13/01/31 and in the details table against column Ident_pk = 1, you can find that at lease 1 combinaisondes date match against Ident_pk = 1

    If you see Ident_pk = 2, then you can't find all the effective_date and termination_date against its corresponding cov_effective_date and termination_date Ident_pk...

    Same as 3

    -----------

    Summary is that there are date range in the ident against agreement_id and Ident_pk table and at least a range of dates even should be exist in detail table is ident_dtl against Ident_pk and if not then show that agreement_id and Ident_pk .

    I made this task using PL/SQL, but I think that there is a way to do the same task in SQL. Guide and if you have any questions then please let me know. Thank you

    Concerning

    Shu


    Hello

    To be considered as a football game, the same line in ident_dtl must have effective_date and termination_date correspondence?

    If so, a solution is:

    SELECT i.agreement_id

    i.ident_pk

    Ident I have

    LEFT OUTER JOIN ident_dtl d.ident_pk d = i.ident_pk

    AND d.effective_date = i.cov_effective_date

    AND d.termination_date = i.cov_termination_date

    WHERE d.ident_pk IS NULL

    ;

    Another pure SQL approach to such problems is to use an EXISTS subquery.

  • Extend a range of dates

    I have the following query, which works without problem. This will expand the range of dates, proof of identity, in a list of dates for me:
    SELECT     j_id
              ,  date_1
               + LEVEL
               - 1
                 datum
    FROM       (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
                FROM   DUAL)
    CONNECT BY LEVEL <= (  date_2
                         - date_1
                         + 1);
    How can I do this for more than 1 sheet well? for example
    SELECT     j_id
              ,  date_1
               + LEVEL
               - 1
                 datum
    FROM       (SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
                FROM   DUAL
                UNION
                SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2
                FROM   DUAL)
    CONNECT BY LEVEL <= (  date_2
                         - date_1
                         + 1);
    Thank you.

    Hello

    Here's one way:

    WITH   cntr          AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX (date_2 - date_1)     AS max_dif
                  FROM    table_x
              )
         CONNECT BY     LEVEL <= 1 + max_dif
    )
    SELECT       x.j_id
    ,       x.date_1 + c.n
    FROM       table_x  x
    JOIN       cntr        c  ON  c.n <= x.date_2 - x.date_1
    ORDER BY  x.j_id
    ,            c.n
    ;
    

    If you do any filtering, it may be more effective to do this first. Start the WITH clause with a subquery that performs filtering, then use this result placed instead of your full table in the view online within the cntr as well as in the main query.
    For example:

    CREATE TABLE  table_x         AS
             SELECT 123 j_id, TO_DATE('01/01/2012', 'DD/MM/YYYY') date_1, TO_DATE('31/01/2012', 'DD/MM/YYYY') date_2
                FROM   DUAL
                UNION
                SELECT 456 j_id, TO_DATE('01/02/2012', 'DD/MM/YYYY') date_1, TO_DATE('29/02/2012', 'DD/MM/YYYY') date_2
                FROM   DUAL
    UNION         SELECT 999,          TO_DATE ('01/01/2013', 'DD/MM/YYYY'),     TO_DATE ('31/12/2013', 'DD/MM/YYYY')     FROM dual
    ;
    
    WITH     filtered_data     AS
    (
         SELECT     *
         FROM     table_x
         WHERE     date_1     < TO_DATE ('01/07/2012', 'DD/MM/YYYY')
    )
    ,        cntr          AS
    (
         SELECT     LEVEL - 1     AS n
         FROM     (
                  SELECT  MAX (date_2 - date_1)     AS max_dif
                  FROM    filtered_data
              )
         CONNECT BY     LEVEL <= 1 + max_dif
    )
    SELECT       f.j_id
    ,       f.date_1 + c.n
    FROM       filtered_data  f
    JOIN       cntr              c  ON   c.n  <= f.date_2 - f.date_1
    ORDER BY  f.j_id
    ,            c.n
    ;
    

    Published by: Frank Kulash, 27 January 2012 10:10
    Posted filtering example

  • How to get the last day of the year

    Hi all

    Thanks in advance...

    How do I get the last day of the year that I'm passing date at run time.

    I can manage to get the first day of the year by
    SELECT TRUNC(SYSDATE,'YEAR') AS FDAY_YEAR
    of the double

    Thanks in advance

    Concerning
    Sachin
      1*  select ADD_MONTHS(trunc(sysdate,'yyyy'),12)-1 dd from dual
    SQL> /
    
    DD
    -----------
    31-DEC-2010
    

Maybe you are looking for

  • HP Envy 15-k201na: restore to the factory settings corrupts the files/windows Boot Manager

    I wanted to restore my computer laptop back to factory settings. So I went into settings and navigated to the update and recovery, recovery and then clicked the option restore factory settings. I had several partitions then asked me if I wanted to de

  • LabVIEW 2012 and DDE

    Hello I'm looking for the DDE library @ labview\vi.lib\platform\dde.llb without success.  It seems that I don't have this library.  Is it possible that I can get dde.llb elsewhere? Thank you in advance, -Jason

  • bar low tabbed pane size

    Anyone know where I can find the size in pixels of the bar at the bottom of the pane tabs?  I'm trying to understand how I pretty much available to avoid having to scroll screen space.

  • brightness settings problems

    Hello, the problem I encounter is that I can't change my brightness settings. I use a pc windows 7 and have a HP monitor. any help would be appreciated.

  • Missing browser and taskbar in internet explore.

    All of a sudden yesterday my browser bar and the task bar left on the screen at all times (I think that someone accidentally hit a key on the keyboard).  If I'm right, click the browser presents itself, but I have to leave internet explore to get the