Date ranges query

Hi Experts,

A very happy new year to all of you (a little in advance)!

I have a table where I have the id of employee and the task assigned with the start dates and end dates. Overlap in the dates of the tasks is a data delivers however I know how to spot them and eliminate. There is therefore no date of tasks that overlap

Employee_id

Task_No

Task_Start_date

Task_End_Date

Examples of data

1 T1 1 January 2014 February 28, 2014

1 T2 March 1, 2014 31 December 2014

2 T1 23 January 2014 31 December 2014

2 T2 1 January 2015 December 31, 2073 (means end of time)

3 T3 1 January 2014 July 15, 2014

3 T4 August 1, 2014 31 December 2014

T5 4 1 January 2014 December 31, 2073

I want to design a query where I provide the end date and it will list all the employees that are free for the same day from 1 January 2014. Thus, for example, if I give December 31, 2014, it will list the

EmpId (first day where the employee is free)

2 January 1, 2014

3 July 16, 2014

If I give the end = end date of time(31-Dec-2013), result-

EmpId (first day where the employee is free)

1 January 1, 2015

2 January 1, 2014

3 July 16, 2014

If I give the end = date January 31, 2014, expected - result

EmpId (first day where the employee is free)

1 January 1, 2015

I conceived after the request, but he intercepted not 2 employee ID. Also, it provides no flexibility to change end date-

Select *.

from (select employe_id,

task_start_date,

task_end_date,

lag (task_end_date, 1, task_start_date) on prev_end_date (partition by employee_id arrested by task_start_date)

of shop.employee_tasks

where task_end_date > = trunc (sysdate))

where task_start_date - prev_end_date > 1

Thanks in advance!

Kind regards

This is an example of what I call the query 'free time': you have the dates when you are busy and you want the dates where you are free.

You can find a nice solution for the problem of base here: ask Tom "SQL Query to find gaps in the date ranges" (search for solution of Anthony Boucher). Please note that this solution works even with the date ranges overlap.

To apply the solution here, first create the test data (please do it yourself in the following questions).

create table t(Employee_id, task_no, Task_Start_date, task_end_date)
as select
1, 'T1', to_date('01-jan-2014'), to_date('28-feb-2014') from dual union all select
1, 'T2', to_date('01-Mar-2014'), to_date('31-Dec-2014') from dual union all select
2, 'T1', to_date('23-jan-2014'), to_date('31-dec-2014') from dual union all select
2, 'T2', to_date('01-jan-2015'), to_date('31-dec-2073') from dual union all select
3, 'T3', to_date('01-jan-2014'), to_date('15-jul-2014') from dual union all select
3, 'T4', to_date('01-aug-2014'), to_date('31-dec-2014') from dual union all select
4, 'T5', to_date('01-Jan-2014'), to_date('31-Dec-2073') from dual;

In the query, you must add records for yesterday and for the "end date" you want. This allows you to "free time" before and after the date ranges in your table.

Now, you partition by order of Task_Start_date and employe_id. Using the analytical function of the max (task_end_date), you get the last date of end so far. Add 1 and you get the first time (maybe). To make sure that the date is free, it must be before the next start date.

variable end_date varchar2(64)
exec :end_date := '31-Dec-2073';
--
with boundaries as (
  select trunc(sysdate)-1 task_start_date, trunc(sysdate)-1 task_end_date from dual
  union all
  select to_date(:end_date)+1, to_date(:end_date)+1 from dual
), data as (
  select * from t
where task_end_date >= trunc(sysdate)
  and task_start_date < :end_date
  union all
  select distinct a.employee_id, null, b.task_start_date, b.task_end_date
  from t a, boundaries b
)
select employee_id, min(free_start) free_start
from (
  select employee_id,
  max(task_end_date) over (partition by employee_id order by task_start_date)+1 free_start,
  lead(task_start_date) over (partition by employee_id order by task_start_date)-1 free_end
  from data
)
where free_start <= free_end
group by employee_id;
EMPLOYEE_ID FREE_START
1 JANUARY 1, 15
2 1 JANUARY 14
3 16 JULY 14

Tags: Database

Similar Questions

  • Date range of family security

    Yesterday morning, I was able to select the day I wanted to see, but I checked and noticed an updated with no date range in the afternoon.  I want to keep track of that which is seen day after day, not a week.  Help?

    Hello

    Thanks for posting your query on the Microsoft Community.

    We understand that you want to track Web activity report in parental control
    on a daily basis. However, currently, the family safety activity reports Web can
    show only on a weekly basis.

    If you think that the display of the activity report on the Web on a daily basis is a great
    to have the option, you can submit Microsoft using the link below.
    https://Windows.uservoice.com/forums/265757-Windows-feature-suggestions

    Thank you.

  • Copy files from specific date ranges in a Batch file

    I'm trying to copy files from a folder with many subfolders to another drive using a batch file. I want to copy the files in the date ranges specific (e.g. 01/01/2016 to 03/31/2016).

    I use this with Xcopy command:

    xcopy "C:\Users\John\Pictures\*.*" F:\BACKUP\Pictures/s/h/i/y

    It works, but I want to send groups of files by date for the different destination folders. I'm having a problem by specifying a date range in the command line.

    Is this possible with xcopy or robocopy? Does anyone know how to list the date rang in the command?

    Thankss in advance,

    John

    Hello

    Please contact Microsoft Community.

    I understand you wanted to know about the files and folders by using the copy command line.

    I suggest you go through the links below:

    Refer to the suggestion given by SpiritX MS MVP replied on 14 August 2010 and check if that helps:

    http://answers.Microsoft.com/en-us/Windows/Forum/Windows_7-files/how-do-i-use-Xcopy-with-Windows-7/adab8f38-719F-451b-9500-c1d6ce385ad1?auth=1

    If the still the problem persists, I suggest you to post your query on TechNet:

    https://social.technet.Microsoft.com/forums/en-us/b11eb5a3-63dc-4636-82fd-ddc22fd8f2f8/cmd-file-to-copy-file?Forum=MDT

    Feel free to write us again with the status of the issue.

  • To ignore the date ranges that overlap

    Hi guys,.

    I have the tables below

    Periods

    START_DATEEND_DATEID
    30-SEP-0513 OCTOBER 051
    12 OCTOBER 0514 NOVEMBER 052
    15 NOVEMBER 0515 DECEMBER 053

    T1

    DAT_COLIDAMOUNT
    11 OCTOBER 05110
    12 OCTOBER 05110
    16 NOVEMBER 05110

    I need to ignore the remaining date range if it overlaps when comparing dat_col from T1 between the dates of beginning and end of periods table. Always need to consider the first periods

    output something like this

    IDID_1START_DATEEND_DATEDAT_COL
    1130-SEP-0513 OCTOBER 0511 OCTOBER 05
    1130-SEP-0513 OCTOBER 0512 OCTOBER 05
    1315 NOVEMBER 0515 DECEMBER 0516 NOVEMBER 05

    I use query

    Select a.id, b.id, b.start_date, b.end_Date, a.DAT_COL from T1 a, (select id, start_date, end_date periods) b

    where a.dat_col between b.start_Date and b.end_Date

    Group of a.id, b.id, b.start_date, b.end_Date, a.dat_col

    order of b.start_date;

    IDID_1START_DATEEND_DATEDAT_COL
    1130-SEP-0513 OCTOBER 0511 OCTOBER 05
    1130-SEP-0513 OCTOBER 0512 OCTOBER 05
    1212 OCTOBER 0514 NOVEMBER 0512 OCTOBER 05
    1315 NOVEMBER 0515 DECEMBER 0516 NOVEMBER 05

    Test case:

    CREATE TABLE 'PERIODS '.

    ("START_DATE" DATE,

    "END_DATE" DATE,

    'ID '.

    ) ;

    Insert into periods (start_date, end_date, ID) values (to_date('30-SEP-05','DD-MON-RR'),to_date('13-OCT-05','DD-MON-RR'),1);

    Insert into periods (start_date, end_date, ID) values (to_date('12-OCT-05','DD-MON-RR'),to_date('14-NOV-05','DD-MON-RR'),2);

    Insert into periods (start_date, end_date, ID) values (to_date('15-NOV-05','DD-MON-RR'),to_date('15-DEC-05','DD-MON-RR'),3);

    Insert into T1 (DAT_COL, ID) values (to_date('11-OCT-05','DD-MON-RR'), 1);

    Insert into T1 (DAT_COL, ID) values (to_date('12-OCT-05','DD-MON-RR'), 1);

    Insert into T1 (DAT_COL, ID) values (to_date('16-NOV-05','DD-MON-RR'), 1);

    CREATE TABLE 'T1 '.

    (DATE OF THE 'DAT_COL',

    'ID '.

    );

    Hello

    If you really want to use something close to what you posted, then you can do it like this:

    WITH got_r_num AS

    (

    SELECT a.id

    b.id AS id_1

    b.start_date

    b.end_date

    a.dat_col

    , ROW_NUMBER () OVER (PARTITION BY a.id, a.dat_col)

    ORDER BY b.start_date, b.end_date

    ) AS r_num

    FROM one t1

    ,         (

    SELECT id, start_date, end_date

    Periods

    ) b

    WHERE a.dat_col BETWEEN b.start_date

    AND b.end_date

    GROUP BY a.id, b.end_date, a.dat_col, b.start_date and b.id

    )

    SELECT id, id_1, start_date, end_date, dat_col

    OF got_r_num

    WHERE r_num = 1

    ORDER BY start_date

    ;

    Note that the WITH clause, that's essentially what you posted in your first post (with the added r_num column) and the main request is essentially the same as in response #1.

    But why would you do something like that?  View online or GROUP BY allows all.  If you remove them, you get the #1 response solution.

  • Find (weekly) missing date ranges based on the Date of submission

    Nice day:

    I have a table that contains the data with a date of presentation of the report column.  If the requirements are that each employee must submit at least 1 weekly report beginning January 1, 2015, how can I find the weekly reports missing, based on the date of submission of reports.

    The ideas that I had:

    • Left join by partition by date (range between)
    • Create a date dimension view?

    Of course, I'm not sure how to approach this dilemma without creating a query of Monster.  Sometimes the simplest queries mistake me...

    Thank you, Aqua

    Here are the DDL for the table with the information from the presentation report (example):

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

    -The DOF for Table DTS_FORM_SAMPLE

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

    CREATE TABLE 'DTS_FORM_SAMPLE '.

    (NUMBER OF 'ID',

    VARCHAR2 (20) "CLOCK_NUMBER."

    NUMBER OF 'EMP_ID,'

    NUMBER OF "REPORT_TYPE."

    DATE OF THE "SUB_DATE.

    ) ;

    /

    INSERTION of REM in DTS_FORM_SAMPLE

    TOGETHER TO DEFINE

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2896, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2897, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2898, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2899, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2900, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2901, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2902, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2903, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2904, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2920, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2921, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2922, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2923, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2924, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2925, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (2965, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6970, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6971, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6972, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6973, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6978, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6979, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6980, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6981, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6948, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6957, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6958, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6959, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6960, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8938, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8939, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8940, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8941, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8942, 'XX2444', 12810,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8943, 'XX2444', 12810,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8977, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8978, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8979, 'XX2444', 12810,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8980, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8981, 'XX2444', 12810,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8982, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8983, 'XX2444', 12810,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8984, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8985, 'XX2444', 12810,1, to_date('02-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8953, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9824, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9825, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9826, 'XX2444', 12810,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8972, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8973, 'XX2444', 12810,1, to_date('30-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8974, 'XX2444', 12810,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8975, 'XX2444', 12810,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8951, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8952, 'XX2444', 12810,1, to_date('19-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8954, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8955, 'XX2444', 12810,1, to_date('26-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8956, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8957, 'XX2444', 12810,1, to_date('05-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8958, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8959, 'XX2444', 12810,1, to_date('12-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8960, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8961, 'XX2444', 12810,1, to_date('19-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8962, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8963, 'XX2444', 12810,1, to_date('26-MAR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8964, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8965, 'XX2444', 12810,1, to_date('02-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8966, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8967, 'XX2444', 12810,1, to_date('09-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8968, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8969, 'XX2444', 12810,1, to_date('16-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8970, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8971, 'XX2444', 12810,1, to_date('23-APR-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8976, 'XX2444', 12810,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8986, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8987, 'XX2444', 12810,1, to_date('09-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9041, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9042, 'XX2444', 12810,1, to_date('16-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9043, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9044, 'XX2444', 12810,1, to_date('23-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9045, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9046, 'XX2444', 12810,1, to_date('30-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9047, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9048, 'XX2444', 12810,1, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8944, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8945, 'XX2444', 12810,1, to_date('22-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8946, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8947, 'XX2444', 12810,1, to_date('29-JAN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8948, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8949, 'XX2444', 12810,1, to_date('05-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (8950, 'XX2444', 12810,1, to_date('12-FEB-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9527, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9528, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (9529, 'XX2444', 12810,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6739, 'YY7223', 11093,8, to_date('15-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6740, 'YY7223', 11093,8, to_date('21-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6741, 'YY7223', 11093,8, to_date('22-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6742, 'YY7223', 11093,8, to_date('25-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6743, 'YY7223', 11093,8, to_date('26-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6744, 'YY7223', 11093,8, to_date('27-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6745, 'YY7223', 11093,1, to_date('04-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6746, 'YY7223', 11093,1, to_date('11-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6747, 'YY7223', 11093,1, to_date('18-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6748, 'YY7223', 11093,1, to_date('25-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6749, 'YY7223', 11093,11, to_date('01-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6750, 'YY7223', 11093,11, to_date('15-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (6751, 'YY7223', 11093,10, to_date('01-JUL-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11017, 'YY7223', 11093,1, to_date('07-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11018, 'YY7223', 11093,1, to_date('14-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11019, 'YY7223', 11093,1, to_date('21-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11020, 'YY7223', 11093,1, to_date('28-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11021, 'YY7223', 11093,1, to_date('04-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11022, 'YY7223', 11093,1, to_date('11-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11023, 'YY7223', 11093,1, to_date('18-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11024, 'YY7223', 11093,1, to_date('25-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11025, 'YY7223', 11093,10, to_date('31-MAY-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (11026, 'YY7223', 11093,10, to_date('30-JUN-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13115, 'YY7223', 11093,1, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13201, 'YY7223', 11093,1, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13287, 'YY7223', 11093,1, to_date('27-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13373, 'YY7223', 11093,10, to_date('08-SEP-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13489, 'YY7223', 11093,8, to_date('01-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13490, 'YY7223', 11093,8, to_date('02-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13491, 'YY7223', 11093,8, to_date('03-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13492, 'YY7223', 11093,8, to_date('04-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13493, 'YY7223', 11093,8, to_date('05-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13494, 'YY7223', 11093,8, to_date('06-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13495, 'YY7223', 11093,8, to_date('07-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13496, 'YY7223', 11093,8, to_date('08-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13497, 'YY7223', 11093,8, to_date('09-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13498, 'YY7223', 11093,8, to_date('10-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13499, 'YY7223', 11093,8, to_date('11-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13500, 'YY7223', 11093,8, to_date('12-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13501, 'YY7223', 11093,8, to_date('13-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13502, 'YY7223', 11093,8, to_date('14-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13503, 'YY7223', 11093,8, to_date('15-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13504, 'YY7223', 11093,8, to_date('16-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13505, 'YY7223', 11093,8, to_date('17-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13506, 'YY7223', 11093,8, to_date('18-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13507, 'YY7223', 11093,8, to_date('19-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13508, 'YY7223', 11093,8, to_date('20-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13509, 'YY7223', 11093,8, to_date('21-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13510, 'YY7223', 11093,8, to_date('22-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13511, 'YY7223', 11093,8, to_date('23-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13512, 'YY7223', 11093,8, to_date('24-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13513, 'YY7223', 11093,8, to_date('25-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13514, 'YY7223', 11093,8, to_date('26-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13515, 'YY7223', 11093,8, to_date('27-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13516, 'YY7223', 11093,8, to_date('28-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13517, 'YY7223', 11093,8, to_date('29-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13518, 'YY7223', 11093,8, to_date('30-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13519, 'YY7223', 11093,8, to_date('31-AUG-15','DD-MON-RR'));

    Insert into DTS_FORM_SAMPLE (ID, CLOCK_NUMBER, EMP_ID, REPORT_TYPE, SUB_DATE) values (13030, 'YY7223', 11093,1, to_date('06-AUG-15','DD-MON-RR'));

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

    -Table DTS_FORM_SAMPLE constraints

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

    CHANGE ALTER TABLE 'DTS_FORM_SAMPLE' ('ID' ENABLE NOT NULL);

    /

    Or more simple:

    Select emp_id, w.wk, to_char (wk, 'ww') x

    from (select trunc (date ' 2015-01-01' + 7 * (level - 1), 'ww') wk)

    of the double

    connect by level<=>

    ) o

    left outer join

    s dts_form_sample

    by (emp_id) partition

    We trunc (s.sub_date, 'ww') = w.wk

    where sub_date is null

    order to emp_id,

    x

    /

    EMP_ID WK X
    ---------- --------- --
    11093 1ST JANUARY 15 01
    11093 8 JANUARY 15 02
    11093 15 JANUARY 15 03
    11093 22 JANUARY 15 04
    11093 29 JANUARY 15 05
    11093 5 FEBRUARY 15 06
    11093 12 FEBRUARY 15 07
    11093 19 FEBRUARY 15 08
    11093 26 FEBRUARY 15 09
    11093 5 MARCH 15 10
    11093 12 MARCH 15 11

    EMP_ID WK X
    ---------- --------- --
    11093 19 MARCH 15 12
    11093 26 MARCH 15 13
    11093 2 APRIL 15 14
    11093 9 APRIL 15 15
    11093 16 APRIL 15 16
    11093 23 APRIL 15 17
    11093 30 APRIL 15 18
    11093 37 15 - SEP - 10
    17-SEVEN 11093.-15 38
    24-SEVEN 11093.-15 39
    11093 1 OCTOBER 15 40

    EMP_ID WK X
    ---------- --------- --
    11093 8 OCTOBER 15 41
    11093 15 OCTOBER 15 42
    11093 22 OCTOBER 15 43
    11093 29 OCTOBER 15 44
    11093 5 NOVEMBER 15 45
    11093 12 NOVEMBER 15 46
    11093 19 NOVEMBER 15 47
    11093 26 NOVEMBER 15 48
    11093 3 DECEMBER 15 49
    11093 10 DECEMBER 15 50
    11093 17 DECEMBER 15 51

    EMP_ID WK X
    ---------- --------- --
    11093 24 DECEMBER 15 52
    11093 31 DECEMBER 15 53
    12810 1ST JANUARY 15 01
    12810 8 JANUARY 15 02
    12810 15 JANUARY 15 03
    12810 27 AUGUST 15 35
    12810 15 - SEP - 03 36
    12810 37 15 - SEP - 10
    17-SEVEN 12810.-15 38
    24-SEVEN 12810.-15 39
    12810 1 OCTOBER 15 40

    EMP_ID WK X
    ---------- --------- --
    12810 8 OCTOBER 15 41
    12810 15 OCTOBER 15 42
    12810 22 OCTOBER 15 43
    12810 29 OCTOBER 15 44
    12810 5 NOVEMBER 15 45
    12810 12 NOVEMBER 15 46
    12810 19 NOVEMBER 15 47
    12810 26 NOVEMBER 15 48
    12810 3 DECEMBER 15 49
    12810 10 DECEMBER 15 50
    12810 17 DECEMBER 15 51

    EMP_ID WK X
    ---------- --------- --
    12810 24 DECEMBER 15 52
    12810 31 DECEMBER 15 53

    57 selected lines.

    SQL >

    However OP question must answer is start of week date.

    SY.

  • Date range prompt--Null default value

    Hello

    It is a follow-up on post Date invites default NULL

    I have a similar case but using database directly request the report and have implemented a variable presentation with two date ranges. I want to leave the default value of the date white values in the dash prompt, but have the ability to enter values in the other guests and ignore the date of the application

    I have 4 variables of presentation being placed in the SQL query, two of which are the date ranges (between)

    I use OBIEE 10.3.1.4, is there a workaround to run the report using the other prompt values and ignoring the date values null?

    Hello

    Keep your 1900 filter in report itself and no default value chosen at the prompt. If this value is not visible in the dashboard and it will fly too when the user selects a value from the command prompt.

    Thank you

    AJ

  • Date range search

    Hello
    Filtering data for a specific date range does not give the desired result. Currently, the column is a column varchar2.

    Then under query should display the records only 2 for the range of data between 01/01/2013, but his displays all records. Please notify.

    Sample data:


    create table Records_test (B_Recorded_Date VARCHAR2 (4000 BYTE))

    insert into Records_test values('12/04/2013');
    insert into Records_test values('7/25/2000');
    insert into Records_test values('10/30/2003');
    insert into Records_test values('9/5/2006');
    insert into Records_test values('12/5/1994');
    insert into Records_test values('12/19/2013');
    insert into Records_test values('9/4/1992');
    insert into Records_test values('8/7/2007');
    insert into Records_test values('9/28/2005');
    insert into Records_test values('12/10/2004');
    insert into Records_test values('11/28/2011');

    Select * from Records_test
    where
    (
    TO_CHAR (TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY'), ' MM/DD/YYYY') > = to_char (to_date('07/01/2013','MM/DD/YYYY'), ' MM/DD/YYYY')
    and to_char (TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY'), ' MM/DD/YYYY') < to_char (to_date('12/31/2013','MM/DD/YYYY'), ' MM/DD/YYYY')
    )

    04/12/2013
    25/07/2000
    30/10/2003
    05/09/2006
    05/12/1994
    19/12/2013
    04/09/1992
    08/07/2007
    28/09/2005
    10/12/2004
    28/11/2011

    Thank you.

    Hello user7988

    Try this:

    SELECT *.

    OF Records_test

    WHERE

    TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY') > = TO_DATE('07/01/2013','MM/DD/YYYY')

    AND TO_date (substr (B_Recorded_Date, 0, 10), ' MM/DD/YYYY')<>

    ;

    The best way if you set this column as DATE, then there is no need to convert your varchar value date.

    Kind regards
    David

  • How to get the second Monday of each month in a given date range?

    In Oracle forms, how to get the second Monday of each month in a given date range?

    I tried below using the query WITH the Clause, but it seems that WITH Clause does not work in Oracle forms. So is there another way to do this in Oracle forms?

    WITH month_range AS

    (

    SELECT TO_DATE ('Dec 2013', 'Mon YYYY') AS first_month

    , TO_DATE ('Mar 2014', 'Mon YYYY') AS last_month

    OF the double

    )

    SELECT NEXT_DAY (6 + ADD_MONTHS (first_month

    , LEVEL - 1

    )

    , 'MONDAY '.

    ) AS second_monday

    OF month_range

    CONNECTION OF LEVEL < = 1 + MONTHS_BETWEEN (last_month, first_month)

    ;

    Thanks in advance.

    Good fishing, when the first day of the month is Thursday... So I changed the query accordingly... Try the below

    SELECT CASE WHEN TO_CHAR (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'DY') = 'game '.

    THEN NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'THU')

    Of OTHER NEXT_DAY (ADD_MONTHS (TRUNC(startdate,'MM'),(LEVEL-1)), 'Game') + 7

    END AS second_day

    FROM (SELECT SYSDATE startdate,

    SYSDATE + 300 enddate

    THE DOUBLE)

    CONNECT BY LEVEL<=>

  • How to list the Dates of broken lines date range?

    Hello

    I have a table with id columns, start_date, end_date with following sample data:
    ID    start_date       end_date
    15    10-Mar-2010      15-Sep-2010
    15    01-Dec-2010      31-Mar-2011
    15    05_Apr-2011      31-Dec-2030
    I entered date range from 1 April 2010 to 31-Jun-2011 and id = 15.
    I want to write a query to print the dates by top lines that are present in a given date range. I will skip the dates which are not present in the rows and which are out of the input range.

    For example I'll print from April 1, 2010... to... 15-sep-2010 pass dates of 16-Sep-2010... to the... November 30, 2010
    printing date of December 1, 2010... to 31 March 2011 and then pass date of April 1, 2011-April 4, 2011 and at the end it will print the dates of April 5, 2011 to 31-Jun-2011

    Please help write a select statement.

    Thank you very much.

    Or like this?

    SQL> ed
    Wrote file afiedt.buf
    
      1  with t as (select 15 as ID, date '2010-03-10' as start_date, date '2010-09-15' as end_date from dual union all
      2             select 15, date '2010-12-01', date '2011-03-31' from dual union all
      3             select 15, date '2011-04-05', date '2030-12-31' from dual)
      4      ,r as (select date '2010-04-01' as d1, date '2011-06-30' as d2 from dual) -- Note June only has 30 days
      5  --
      6  --
      7  --
      8  select (start_date+rn)-1 dt
      9  from t
     10      ,(select rownum as rn from dual connect by rownum <= (select max((end_date-start_date)+1) from t))
     11      ,r
     12  where   (start_date+rn)-1 <= end_date
     13  and     (start_date+rn)-1 between d1 and d2
     14* order by 1
    SQL> /
    
    DT
    --------------------
    01-APR-2010 00:00:00
    02-APR-2010 00:00:00
    03-APR-2010 00:00:00
    04-APR-2010 00:00:00
    05-APR-2010 00:00:00
    06-APR-2010 00:00:00
    07-APR-2010 00:00:00
    08-APR-2010 00:00:00
    09-APR-2010 00:00:00
    10-APR-2010 00:00:00
    11-APR-2010 00:00:00
    12-APR-2010 00:00:00
    13-APR-2010 00:00:00
    14-APR-2010 00:00:00
    15-APR-2010 00:00:00
    16-APR-2010 00:00:00
    17-APR-2010 00:00:00
    18-APR-2010 00:00:00
    19-APR-2010 00:00:00
    20-APR-2010 00:00:00
    21-APR-2010 00:00:00
    22-APR-2010 00:00:00
    23-APR-2010 00:00:00
    24-APR-2010 00:00:00
    25-APR-2010 00:00:00
    26-APR-2010 00:00:00
    27-APR-2010 00:00:00
    28-APR-2010 00:00:00
    29-APR-2010 00:00:00
    30-APR-2010 00:00:00
    01-MAY-2010 00:00:00
    02-MAY-2010 00:00:00
    03-MAY-2010 00:00:00
    04-MAY-2010 00:00:00
    05-MAY-2010 00:00:00
    06-MAY-2010 00:00:00
    07-MAY-2010 00:00:00
    08-MAY-2010 00:00:00
    09-MAY-2010 00:00:00
    10-MAY-2010 00:00:00
    11-MAY-2010 00:00:00
    12-MAY-2010 00:00:00
    13-MAY-2010 00:00:00
    14-MAY-2010 00:00:00
    15-MAY-2010 00:00:00
    16-MAY-2010 00:00:00
    17-MAY-2010 00:00:00
    18-MAY-2010 00:00:00
    19-MAY-2010 00:00:00
    20-MAY-2010 00:00:00
    21-MAY-2010 00:00:00
    22-MAY-2010 00:00:00
    23-MAY-2010 00:00:00
    24-MAY-2010 00:00:00
    25-MAY-2010 00:00:00
    26-MAY-2010 00:00:00
    27-MAY-2010 00:00:00
    28-MAY-2010 00:00:00
    29-MAY-2010 00:00:00
    30-MAY-2010 00:00:00
    31-MAY-2010 00:00:00
    01-JUN-2010 00:00:00
    02-JUN-2010 00:00:00
    03-JUN-2010 00:00:00
    04-JUN-2010 00:00:00
    05-JUN-2010 00:00:00
    06-JUN-2010 00:00:00
    07-JUN-2010 00:00:00
    08-JUN-2010 00:00:00
    09-JUN-2010 00:00:00
    10-JUN-2010 00:00:00
    11-JUN-2010 00:00:00
    12-JUN-2010 00:00:00
    13-JUN-2010 00:00:00
    14-JUN-2010 00:00:00
    15-JUN-2010 00:00:00
    16-JUN-2010 00:00:00
    17-JUN-2010 00:00:00
    18-JUN-2010 00:00:00
    19-JUN-2010 00:00:00
    20-JUN-2010 00:00:00
    21-JUN-2010 00:00:00
    22-JUN-2010 00:00:00
    23-JUN-2010 00:00:00
    24-JUN-2010 00:00:00
    25-JUN-2010 00:00:00
    26-JUN-2010 00:00:00
    27-JUN-2010 00:00:00
    28-JUN-2010 00:00:00
    29-JUN-2010 00:00:00
    30-JUN-2010 00:00:00
    01-JUL-2010 00:00:00
    02-JUL-2010 00:00:00
    03-JUL-2010 00:00:00
    04-JUL-2010 00:00:00
    05-JUL-2010 00:00:00
    06-JUL-2010 00:00:00
    07-JUL-2010 00:00:00
    08-JUL-2010 00:00:00
    09-JUL-2010 00:00:00
    10-JUL-2010 00:00:00
    11-JUL-2010 00:00:00
    12-JUL-2010 00:00:00
    13-JUL-2010 00:00:00
    14-JUL-2010 00:00:00
    15-JUL-2010 00:00:00
    16-JUL-2010 00:00:00
    17-JUL-2010 00:00:00
    18-JUL-2010 00:00:00
    19-JUL-2010 00:00:00
    20-JUL-2010 00:00:00
    21-JUL-2010 00:00:00
    22-JUL-2010 00:00:00
    23-JUL-2010 00:00:00
    24-JUL-2010 00:00:00
    25-JUL-2010 00:00:00
    26-JUL-2010 00:00:00
    27-JUL-2010 00:00:00
    28-JUL-2010 00:00:00
    29-JUL-2010 00:00:00
    30-JUL-2010 00:00:00
    31-JUL-2010 00:00:00
    01-AUG-2010 00:00:00
    02-AUG-2010 00:00:00
    03-AUG-2010 00:00:00
    04-AUG-2010 00:00:00
    05-AUG-2010 00:00:00
    06-AUG-2010 00:00:00
    07-AUG-2010 00:00:00
    08-AUG-2010 00:00:00
    09-AUG-2010 00:00:00
    10-AUG-2010 00:00:00
    11-AUG-2010 00:00:00
    12-AUG-2010 00:00:00
    13-AUG-2010 00:00:00
    14-AUG-2010 00:00:00
    15-AUG-2010 00:00:00
    16-AUG-2010 00:00:00
    17-AUG-2010 00:00:00
    18-AUG-2010 00:00:00
    19-AUG-2010 00:00:00
    20-AUG-2010 00:00:00
    21-AUG-2010 00:00:00
    22-AUG-2010 00:00:00
    23-AUG-2010 00:00:00
    24-AUG-2010 00:00:00
    25-AUG-2010 00:00:00
    26-AUG-2010 00:00:00
    27-AUG-2010 00:00:00
    28-AUG-2010 00:00:00
    29-AUG-2010 00:00:00
    30-AUG-2010 00:00:00
    31-AUG-2010 00:00:00
    01-SEP-2010 00:00:00
    02-SEP-2010 00:00:00
    03-SEP-2010 00:00:00
    04-SEP-2010 00:00:00
    05-SEP-2010 00:00:00
    06-SEP-2010 00:00:00
    07-SEP-2010 00:00:00
    08-SEP-2010 00:00:00
    09-SEP-2010 00:00:00
    10-SEP-2010 00:00:00
    11-SEP-2010 00:00:00
    12-SEP-2010 00:00:00
    13-SEP-2010 00:00:00
    14-SEP-2010 00:00:00
    15-SEP-2010 00:00:00
    01-DEC-2010 00:00:00
    02-DEC-2010 00:00:00
    03-DEC-2010 00:00:00
    04-DEC-2010 00:00:00
    05-DEC-2010 00:00:00
    06-DEC-2010 00:00:00
    07-DEC-2010 00:00:00
    08-DEC-2010 00:00:00
    09-DEC-2010 00:00:00
    10-DEC-2010 00:00:00
    11-DEC-2010 00:00:00
    12-DEC-2010 00:00:00
    13-DEC-2010 00:00:00
    14-DEC-2010 00:00:00
    15-DEC-2010 00:00:00
    16-DEC-2010 00:00:00
    17-DEC-2010 00:00:00
    18-DEC-2010 00:00:00
    19-DEC-2010 00:00:00
    20-DEC-2010 00:00:00
    21-DEC-2010 00:00:00
    22-DEC-2010 00:00:00
    23-DEC-2010 00:00:00
    24-DEC-2010 00:00:00
    25-DEC-2010 00:00:00
    26-DEC-2010 00:00:00
    27-DEC-2010 00:00:00
    28-DEC-2010 00:00:00
    29-DEC-2010 00:00:00
    30-DEC-2010 00:00:00
    31-DEC-2010 00:00:00
    01-JAN-2011 00:00:00
    02-JAN-2011 00:00:00
    03-JAN-2011 00:00:00
    04-JAN-2011 00:00:00
    05-JAN-2011 00:00:00
    06-JAN-2011 00:00:00
    07-JAN-2011 00:00:00
    08-JAN-2011 00:00:00
    09-JAN-2011 00:00:00
    10-JAN-2011 00:00:00
    11-JAN-2011 00:00:00
    12-JAN-2011 00:00:00
    13-JAN-2011 00:00:00
    14-JAN-2011 00:00:00
    15-JAN-2011 00:00:00
    16-JAN-2011 00:00:00
    17-JAN-2011 00:00:00
    18-JAN-2011 00:00:00
    19-JAN-2011 00:00:00
    20-JAN-2011 00:00:00
    21-JAN-2011 00:00:00
    22-JAN-2011 00:00:00
    23-JAN-2011 00:00:00
    24-JAN-2011 00:00:00
    25-JAN-2011 00:00:00
    26-JAN-2011 00:00:00
    27-JAN-2011 00:00:00
    28-JAN-2011 00:00:00
    29-JAN-2011 00:00:00
    30-JAN-2011 00:00:00
    31-JAN-2011 00:00:00
    01-FEB-2011 00:00:00
    02-FEB-2011 00:00:00
    03-FEB-2011 00:00:00
    04-FEB-2011 00:00:00
    05-FEB-2011 00:00:00
    06-FEB-2011 00:00:00
    07-FEB-2011 00:00:00
    08-FEB-2011 00:00:00
    09-FEB-2011 00:00:00
    10-FEB-2011 00:00:00
    11-FEB-2011 00:00:00
    12-FEB-2011 00:00:00
    13-FEB-2011 00:00:00
    14-FEB-2011 00:00:00
    15-FEB-2011 00:00:00
    16-FEB-2011 00:00:00
    17-FEB-2011 00:00:00
    18-FEB-2011 00:00:00
    19-FEB-2011 00:00:00
    20-FEB-2011 00:00:00
    21-FEB-2011 00:00:00
    22-FEB-2011 00:00:00
    23-FEB-2011 00:00:00
    24-FEB-2011 00:00:00
    25-FEB-2011 00:00:00
    26-FEB-2011 00:00:00
    27-FEB-2011 00:00:00
    28-FEB-2011 00:00:00
    01-MAR-2011 00:00:00
    02-MAR-2011 00:00:00
    03-MAR-2011 00:00:00
    04-MAR-2011 00:00:00
    05-MAR-2011 00:00:00
    06-MAR-2011 00:00:00
    07-MAR-2011 00:00:00
    08-MAR-2011 00:00:00
    09-MAR-2011 00:00:00
    10-MAR-2011 00:00:00
    11-MAR-2011 00:00:00
    12-MAR-2011 00:00:00
    13-MAR-2011 00:00:00
    14-MAR-2011 00:00:00
    15-MAR-2011 00:00:00
    16-MAR-2011 00:00:00
    17-MAR-2011 00:00:00
    18-MAR-2011 00:00:00
    19-MAR-2011 00:00:00
    20-MAR-2011 00:00:00
    21-MAR-2011 00:00:00
    22-MAR-2011 00:00:00
    23-MAR-2011 00:00:00
    24-MAR-2011 00:00:00
    25-MAR-2011 00:00:00
    26-MAR-2011 00:00:00
    27-MAR-2011 00:00:00
    28-MAR-2011 00:00:00
    29-MAR-2011 00:00:00
    30-MAR-2011 00:00:00
    31-MAR-2011 00:00:00
    05-APR-2011 00:00:00
    06-APR-2011 00:00:00
    07-APR-2011 00:00:00
    08-APR-2011 00:00:00
    09-APR-2011 00:00:00
    10-APR-2011 00:00:00
    11-APR-2011 00:00:00
    12-APR-2011 00:00:00
    13-APR-2011 00:00:00
    14-APR-2011 00:00:00
    15-APR-2011 00:00:00
    16-APR-2011 00:00:00
    17-APR-2011 00:00:00
    18-APR-2011 00:00:00
    19-APR-2011 00:00:00
    20-APR-2011 00:00:00
    21-APR-2011 00:00:00
    22-APR-2011 00:00:00
    23-APR-2011 00:00:00
    24-APR-2011 00:00:00
    25-APR-2011 00:00:00
    26-APR-2011 00:00:00
    27-APR-2011 00:00:00
    28-APR-2011 00:00:00
    29-APR-2011 00:00:00
    30-APR-2011 00:00:00
    01-MAY-2011 00:00:00
    02-MAY-2011 00:00:00
    03-MAY-2011 00:00:00
    04-MAY-2011 00:00:00
    05-MAY-2011 00:00:00
    06-MAY-2011 00:00:00
    07-MAY-2011 00:00:00
    08-MAY-2011 00:00:00
    09-MAY-2011 00:00:00
    10-MAY-2011 00:00:00
    11-MAY-2011 00:00:00
    12-MAY-2011 00:00:00
    13-MAY-2011 00:00:00
    14-MAY-2011 00:00:00
    15-MAY-2011 00:00:00
    16-MAY-2011 00:00:00
    17-MAY-2011 00:00:00
    18-MAY-2011 00:00:00
    19-MAY-2011 00:00:00
    20-MAY-2011 00:00:00
    21-MAY-2011 00:00:00
    22-MAY-2011 00:00:00
    23-MAY-2011 00:00:00
    24-MAY-2011 00:00:00
    25-MAY-2011 00:00:00
    26-MAY-2011 00:00:00
    27-MAY-2011 00:00:00
    28-MAY-2011 00:00:00
    29-MAY-2011 00:00:00
    30-MAY-2011 00:00:00
    31-MAY-2011 00:00:00
    01-JUN-2011 00:00:00
    02-JUN-2011 00:00:00
    03-JUN-2011 00:00:00
    04-JUN-2011 00:00:00
    05-JUN-2011 00:00:00
    06-JUN-2011 00:00:00
    07-JUN-2011 00:00:00
    08-JUN-2011 00:00:00
    09-JUN-2011 00:00:00
    10-JUN-2011 00:00:00
    11-JUN-2011 00:00:00
    12-JUN-2011 00:00:00
    13-JUN-2011 00:00:00
    14-JUN-2011 00:00:00
    15-JUN-2011 00:00:00
    16-JUN-2011 00:00:00
    17-JUN-2011 00:00:00
    18-JUN-2011 00:00:00
    19-JUN-2011 00:00:00
    20-JUN-2011 00:00:00
    21-JUN-2011 00:00:00
    22-JUN-2011 00:00:00
    23-JUN-2011 00:00:00
    24-JUN-2011 00:00:00
    25-JUN-2011 00:00:00
    26-JUN-2011 00:00:00
    27-JUN-2011 00:00:00
    28-JUN-2011 00:00:00
    29-JUN-2011 00:00:00
    30-JUN-2011 00:00:00
    
    376 rows selected.
    
    SQL>
    
  • How to merge two date ranges

    Hello
    I have the rest of the table. I want to merge the date ranges if dates are continuous and the value is the same. I use Oracle 10 g. Help, please.

    START_DATE END_DATE VALUE
    ----------------------------------------------------------------

    1/1/2008 12/31/2008 1234
    1/1/2009 12/31/2009 1234


    Exit statement SQL must be as follows:


    START_DATE END_DATE VALUE
    ----------------------------------------------------------------

    1/1/2008 12/31/2009 1234



    Thanks in advance.

    Published by: user3898545 on January 27, 2010 19:44

    Hello

    user3898545 wrote:
    Hello
    Dates will not overlap but sometimes start_date can be equal to end_date in a row.

    Sorry, I'm not sure of that figure.
    If the query I posted is not giving correct results, post some samples (CREATE TABLE and INSERT statements are best, but a clause WITH as Tubby displayed is correct) and the correct results, you need these data.

    Please suggest if something needs to be done through pl/sql performance is also the key.

    I don't see how the PL/SQL will help in this problem.

    When two lines need to be combined, the end_date ranked sooner than always exactly 24 hours before the start_date on the line later?
    If so:

    WITH     got_grp         AS
    (
         SELECT     data.*
         ,     end_date - SUM (end_date + 1 - start_date) OVER ( PARTITION BY  val
                                                                     ORDER BY       start_date
                                                ) AS grp
         FROM     data
    )
    SELECT       MIN (start_date)     AS start_date
    ,       MAX (end_date)     AS end_date
    ,       val
    FROM       got_grp
    GROUP BY  val
    ,            grp
    ORDER BY  val
    ,            start_date
    ;
    

    Published by: Frank Kulash, 28 January 2010 14:03
    For example, a subquery added.

  • On the date ranges in search of oracle forms

    I use service number, name, type person and date as search criteria in the custom form ranges.
    When I enter the employee number, press the search button, I get the exact info in the block of result.
    Result block contains
    name of the employee, personid, emp numbed, org, start_date.
    Similarly when I enter the employee number, dept, I get the correct values.
    My question is, when I enter the date range. IAM unable to filter the data.
    When I enter START_DATE between nvl(:BLOCKNAME.) Start_date, 1 January 1901 ') and nvl(:BLOCKNAME.) End_date, 31-DEC-4712') where block clause in the result. I had data for the range of dates also.

    If I give condition in where clause results take so long when I search with the name of the employee, number, dept, person type.

    If I have a query with the date, the persormance is good.

    Think you know everything, how it prevents START_DATE between nvl(:BLOCKNAME.) Start_date, 1 January 1901 ') and nvl(:BLOCKNAME.) End_date, 31-DEC-4712') when look us with the employee's name, number, dept, person type.

    So leave the WHERE clause of your empty block and put something like the following in your search button:

    IF    :BLOCK.START_DATE IS NOT NULL
       OR :BLOCK.END_DATE IS NOT NULL THEN
      SET_BLOCK_PROPERTY('YOURBLOCK', ONETIME_WHERE, 'START_DATE between nvl(:BLOCKNAME.START_DATE,TO_DATE(''01-JAN-1901'', ''DD-MON-YYYY'')) and nvl(:BLOCKNAME.END_DATE,TO_DATE(''31-DEC-4712'', ''DD-MON-YYYY''))');
    END IF;
    
  • date range crosses / keys of other dates

    I have the table with columns 'HoldDate' and 'Release Date '.
    I want to ask all the records in the table, with my parameters pDateStart and pDateEnd in this way, which
    the date range [pDateStart.. pDateEnd] keys date range "HoldDate" and "Release Date".

    For example:

    Entry:
    pDateStart = the 20.03.2009
    pDateEnd = 23.03.2009

    1 Record1:
    "HoldDate" | "Release date".
    18.03.2009 | 19.03.2009

    This record NOT be returned by query, because the date range [20.03.2009..23.03.2009] do NOT touch / crosses the date range [18.03.2009..19.03.2009].

    2 Record2:
    "HoldDate" | "Release date".
    18.03.2009 | 21.03.2009

    This record will be returned by the query, because the range [18.03.2009..21.03.2009] dates date range [20.03.2009..23.03.2009] touch / intersect.

    What is the best way to write this condition to the query?

    I think it would be slow in the perfomance:

    WHERE the /pDateStart between HoldDate release date
    GOLD pDateEnd between HoldDate OF release date)

    Any thoughts?

    CharlesRoos wrote:
    I have the table with columns 'HoldDate' and 'Release Date '.
    I want to ask all the records in the table, with my parameters pDateStart and pDateEnd in this way, which
    the date range [pDateStart.. pDateEnd] keys date range "HoldDate" and "Release Date".

    What you need is...

    Where pDateEnd >= HoldDate AND pDateStart <= ReleaseDate
    
  • To add totals in a certain date range

    I have 3 sheets. Income, expenses and then an annual journal (has twelve columns, one for each month). Is there a way to get the numbers to add totals to a column of the spreadsheet of spending within the date range 01/01/16 and 31/01/16 and put the total in a cell in January on my sheet of each year. I can't understand a formula so that it can find the date range. I get a synyax error message.

    Assumptions:

    Your TABLES (not the leaves) are named income, spending and summary. Here is any other tables in the document with these names.

    Dates of expenditure are in column A of the table expenses. Other than the header line, all the entries in this column are values Date and time that have been entered as dates only.

    The amount for each item of expenditure is in column C of the expense table.

    Line 1 of the analytical table is defined as a header line.

    January is in column A of the summary table.

    Summary::A1 cell contains the date January 1, 2016, but can be formatted to display only the name of the month or the month and year. (but see the note below) *.

    Enter the formula in the cell that will contain total expenditures recorded with dates in January 2016 below:

    = SUMIFS ("Expenses: Expenses, $C: $A," > = "& A1, Expenses: $A," < = "& EOMONTH(A1,0))

    Example: All the amounts of expenditure were reduced to 1.00 simple confirmation of funds.

    * NOTE: The formula has previously worked with the format of the cells in the row 1 Summary defined to show only the month and the year (two digits) of the effective date values (the first day of the month indicated), but the table I built tonight January 1, 2015 to the format to display 16 Jan, one was interpreted as January 16 (2016) , and SUMIFS formula did not include not January 1 to January 14 numbers in January total.

    A custom, displaying the month (short or long) and the year (four digits) or a custom format shows only the name of the month (short or long) gave good results.

    Note that any format under control of the display, the effective date is the first of the month displayed.

    Table built and tested in Numbers ' 09 (v 2.3)

    Kind regards

    Barry

  • Conditional formatting depends on the date ranges

    Basically, I want to be able to enter a date in column A and a sum of money in the B column, depending on where the date in column A grave in a date range, I want the money in column B to copy to a corresponding column. Is this possible? The only questions I found on here deal in a conditional formatting with dates have to do with derivative.

    Thank you

    Julio

    I hope this help to clarify for you...

    It is not bringing conditional formatting.  Formatting conditional would change the format of a cell (or cells)... as the font, color, size, color cell background, or other formatting character is tics of a cell based on the contents of the cell

    You ask about including of the value of a cel another beach under certain conditions

    Here is an example:

    The first three rows are header lines.

    You must enter a valid date for the towing job.  Using the format "mm/dd/yyyy".

    C4 = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    It's shorthand dethrone select cell C4, and type (or copy and paste it here) the formula:

    = IF (AND (DATEVALUE (A4) ≥DATEVALUE($B$1), DATEVALUE (A4) ≤DATEVALUE($B$2)), B4, "")

    Select the cell C4, copy

    Select cells C4 at the end of the C column, paste

  • Smart album by date range does not select all the pictures, it should.

    I created a Smart Album with a range of the year.

    Some pictures appear in the Smart Album, but others do not, even though their information shows that their date corresponds to the range.

    I tried a repair of the photo library database, but that did not help.

    Try breaking the rule of date range: a buggy behavior reported in some language settings.

    This version shows more photos?

Maybe you are looking for

  • The Canon 70 d remote flash trigger

    Which Canon speed light will work off camera and be triggered by the functionality of firing the flash in camera remotely?

  • Forcing programs to uninstall

    I can't uninstall a couple of programs using "programs" in the control panel. is there a way I can force the computer to uninstall?

  • printer Officejet 4620 in two States

    I have windows 7 laptop, an hp officejet model 4620 all-in-one printer running on a wireless network in a single State, works very well. Now, I am for another home for the summer and bought the same printer for home #2. So I run the disk of entire pl

  • QOS VoIP

    Need help to understand where to apply QOS VoIP on my VPN network. Using routers C2800 with a private behind the not interface 0/1 address IP networks, only the voice, data and management of the subnets are subinterfaces for example 0/1.1 data, voice

  • My ORB start does not, he will have all the features and the icon disappear, just to the left of the word it

    My ORB start does not, he will have all the features and the icon disappear, just to the left of the word it even using restore window can not solve the problem, I use windows 7 pro, this happen after the update I have install on September 24, 2012