Two dates ranges

Hi Guys,
I have a problem here:
For example
SELECT
emp.id_employe,
taux.id_taux,
emp.nom_emp,
emp.prenom_emp,
taux.taux_tc,
per.periode_debut_tc,
per.periode_fin_tc,
fac.id_facture,
fac.periode_debut_fac,
fac.periode_fin_fac
FROM dtp_spe_factures fac
join dtp_spe_commandes com on COM.ID_COMMANDE = FAC.ID_COMMANDE
join dtp_spe_ao_consortiums con on CON.ID_AO_CONSORTIUM = COM.ID_AO_CONSORTIUM
join dtp_spe_taux_categories taux on TAUX.ID_AO_CONSORTIUM = CON.ID_AO_CONSORTIUM
join dtp_spe_categories cat on CAT.ID_CATEGORIE = TAUX.ID_CATEGORIE
join DTP_SPE_TAUX_PERIODE per on PER.ID_TAUX_PERIODE = TAUX.ID_TAUX_PERIODE
join dtp_spe_employes2 emp on EMP.ID_AO_CONSORTIUM = con.ID_AO_CONSORTIUM and CAT.ID_CATEGORIE = EMP.ID_CATEGORIE
PROBLEM
The first 4 lines
1471     11015     Joe     Billy     82.84     2010-04-01     2011-03-31     4474     2009-12-14     2010-04-29
1471     10989     Joe     Billy     79.56     2008-04-01     2009-03-31     4474     2009-12-14     2010-04-29
1471     11020     Joe     Billy     84.5     2011-04-01     2012-03-31     4474     2009-12-14     2010-04-29
1471     11007     Joe     Billy     81.23     2009-04-01     2010-03-31     4474     2009-12-14     2010-04-29
It supposed to return me just the lines 1 and 4
I tried to use this
periode_debut_fac between periode_debut_tc AND periode_fin_tc
and
periode_fin_fac between periode_debut_tc AND periode_fin_tc
But not worked !! The only way that it worked was when I put this select inside another select, but after it the select get time to execut.
Thanks

The model
http://ericyuri.wordpress.com/?attachment_id=423
the full code is this:
-- THIRD select
-- SELECT TAUX_TC FROM ( ...
select
NOM_EMP||', '||PRENOM_EMP ||' P-'|| SEQ AS D,
id_view
from (
SELECT ROW_NUMBER () OVER (PARTITION BY id_ao_consortium ORDER BY id_ao_consortium) id_view,
emp.id_employe,
taux.id_taux,
ROW_NUMBER () OVER (PARTITION BY emp.id_employe ORDER BY taux.id_taux) SEQ,
emp.nom_emp,
emp.prenom_emp,
emp.date_debut_emp,
emp.date_fin_emp,
emp.id_ao_consortium,
taux.id_categorie,
taux.taux_tc,
per.periode_debut_tc,
per.periode_fin_tc,
con.num_ao,
con.nom_con,
com.id_commande,
com.code_commande_com,
fac.id_facture,
fac.periode_debut_fac,
fac.periode_fin_fac
FROM dtp_spe_factures fac
join dtp_spe_commandes com on COM.ID_COMMANDE = FAC.ID_COMMANDE
join dtp_spe_ao_consortiums con on CON.ID_AO_CONSORTIUM = COM.ID_AO_CONSORTIUM
join dtp_spe_taux_categories taux on TAUX.ID_AO_CONSORTIUM = CON.ID_AO_CONSORTIUM
join dtp_spe_categories cat on CAT.ID_CATEGORIE = TAUX.ID_CATEGORIE
join DTP_SPE_TAUX_PERIODE per on PER.ID_TAUX_PERIODE = TAUX.ID_TAUX_PERIODE
join dtp_spe_employes2 emp on EMP.ID_AO_CONSORTIUM = con.ID_AO_CONSORTIUM and CAT.ID_CATEGORIE = EMP.ID_CATEGORIE
where id_facture = :P28_ID_FACTURE
where
periode_debut_fac between periode_debut_tc AND periode_fin_tc
or
periode_fin_fac between periode_debut_tc AND periode_fin_tc
order by 1
-- WHERE ID_VIEW = :P28_ID_VIEW
It is working and fast now ..... the problem is when I try to select another things based on id_view ...
if I want to select another thing for example TAUX_TC... I have to use another select, so it gonna be 3 Select :S
I'd like to known just one way more elegant with performance to do it !! It is working but its wierd for me :P !!

Similar Messages

  • Select Between two date ranges from xml file

    Hi ,
    I have a column date_ with datatype VARCHAR2(150) it stores
    data as
    05/19/2010 11:23 AM
    05/20/2010 12:23 PM
    05/22/2010 11:23 AM
    05/25/2010 11:23 AM
    i have to select all the rows between 05/19/2010 and 05/22/2010 how to do that this column is in xml file

    I have a table wit two fields
    Field1 is integer and field2 is xmltype
    in the xmltype i store an xml file
    <ParentNode>
    <Node>
    <Cat>1</Cat>
    <Date>05/19/2010 11:23 AM </Date>
    </Node>
    <Node>
    <Cat>2</Cat>
    <Date>05/20/2010 12:23 PM </Date>
    </Node>
    <Node>
    <Cat>3</Cat>
    <Date>05/22/2010 11:23 AM </Date>
    </Node>
    </Parentnode>
    I am using teh below query to retrive teh result
    SELECT T.Feild1, XML.* FROM Tablename T,
    XMLTable( 'Parentnod/Node' PASSING T.Feild2 COLUMNS Cat NUMBER PATH 'Cat' ,
    DATE_ VARCHAR2(100) PATH 'Date'
    )XML where cat >1;
    now i have to do teh same to select the rows between two date range 05/19/2010 and 05/21/2010
    hope i am able to make teh question simple

  • Combine two date ranges in calender display

    Using Apex 3.2, Oracle 10g, IE7
    I have a calender that displays two date ranges: one that does a total count of assets over a one year period and the other is a breakdown of what assets are scheduled to be in use. I would like to combine them into one display (total - in use). Any suggestions or ideas on combining the date ranges?
    code below * thank you Denes Kubicek *
    select 'a href="f?p=&APP_ID.:27:&SESSION.::NO::'||'P27_TYPE:'||category_name||'">'||('Count Avail: '||to_char(asset))||' /a asset , SYSDATE -1 + LEVEL
    FROM (SELECT (sysdate +365) - sysdate conn_level, count(a.id) asset, b.category_name FROM hd_asset_assets a, hd_asset_categories b WHERE a.category_id = :P23_SEARCH and a.category_id = b.id GROUP BY category_name)
    CONNECT BY LEVEL <= conn_level
    UNION ALL
    SELECT ('In Use: '||b.asset_name) asset , session_date FROM TABLE (SELECT return_table_fn () AS session_table_type FROM DUAL) left join (select asset_name, category_id from hd_asset_assets) b on UPPER(title) = UPPER(b.asset_name) where b.category_id = :P23_SEARCH
    Edited by: tread on Aug 4, 2009 1:29 PM
    Edited by: tread on Aug 4, 2009 1:29 PM

    Hi,
    You would probably have to simplify the existing statement and then wrap it within another select statement that does a GROUP BY over the date column:
    SELECT Datecolumn, AssetName, SUM(Total)-SUM(InUse) Available
    FROM (
    ...your existing select statements ensuring that both statements return the same number/names of columns...
    GROUP BY DateColumn, AssetNameAndy

  • Extracting a count of distinct values between two date ranges over months

    Hi All,
    I am having a bit of difficulty in figuring out the query to build a list of active campaigns over a date range.
    i.e. I have a table with campaign IDs and their start and end date details like this
    Campaign_id     Start_date     End_date
            10001     1-Jun-09     31-May-11
            10002     1-Jun-09     23-Jun-11
            30041     21-Aug-09     31-Dec-09
            20005     3-Jun-10     31-May-11
            90021     21-Nov-09     30-Nov-10
            54000     1-Jun-11     1-Dec-12
            35600     1-Mar-10     31-Mar-12 What the above data means is, for eg. the campaign 10001 is active from 1-Jun-09 to 31-May-11 i.e. for 24 months (inclusive of the month Jun-09 and May-11)
    What I need to figure out is the counts of active campaigns between a date range and display that active count at a month level (for e.g. lets say we want to see all the campaigns that were active
    between the date range '01-JUN-2007' and '30-APR-2012' ). So the partial output would be as seen below. The list would continue till december-2012
    Month    Year    Count of active campaigns
    Jan    2009    0
    Feb    2009    0
    Mar    2009    0
    Apr    2009    0
    May    2009    0
    Jun    2009    2
    Jul    2009    2
    Aug    2009    3
    Sep    2009    3
    Oct    2009    3
    Nov    2009    4
    Dec    2009    4
    Jan    2010    3
    Feb    2010    3
    Mar    2010    4
    Apr    2010    4
    Dec    2012    1 Could anybody please help me with the right query for this.
    Thanks a lot for help
    Regards
    Goldi

    set pagesize 40
    with tab as
                    select 1 id, sysdate -100 start_date, sysdate end_date from dual
                    union
                    select 1 id, sysdate -200 start_date, sysdate -150 end_date from dual
                    union
                    select 1 id, sysdate -600 start_date, sysdate - 400 end_date from dual
                    union
                    select 1 id, sysdate -300 start_date, sysdate - 150 end_date from dual
                    union
                    select 2 id, sysdate -100 start_date, sysdate-50 end_date from dual
          year_tab as
                        select
                                 add_months(min_date, level -1) m
                        from
                                select min(trunc(start_date,'YYYY')) min_date, add_months(max(trunc(end_date,'YYYY')), 12) max_date
                                from tab
                        connect by level <= months_between(max_date, min_date)
    select to_char(m,'YYYY') year_,
             to_char(m,'Month') month_,
             nvl(act, 0) act
    from   year_tab,
                select m date_,count(*)  act
                from tab, year_tab
                where m between trunc(start_date,'MM') and trunc(end_date,'MM')
                group by m
                ) month_tab
    where m = date_(+)
    order by m;
    YEAR_ MONTH_           ACT
    2010  January            0
    2010  February           0
    2010  March              0
    2010  April              0
    2010  May                0
    2010  June               0
    2010  July               0
    2010  August             0
    2010  September          1
    2010  October            1
    2010  November           1
    2010  December           1
    2011  January            1
    2011  February           1
    2011  March              1
    2011  April              0
    2011  May                0
    2011  June               0
    2011  July               1
    2011  August             1
    2011  September          1
    2011  October            2
    2011  November           2
    2011  December           2
    2012  January            2
    2012  February           2
    2012  March              2
    2012  April              1
    2012  May                1
    2012  June               0
    2012  July               0
    2012  August             0
    2012  September          0
    2012  October            0
    2012  November           0
    2012  December           0
    36 rows selected.

  • Function module to calculate no of days between two date ranges

    hi experts,
    can some one please suggest a function module that can calculate no of days between specified date range.
    for example : if i enter date range between 26.02.2011 to 20.05.2011, then it should calculate no of days between these dates.
    Moderator message : Basic date questions not allowed. Read forum rules before posting. Thread locked.
    Edited by: Vinod Kumar on May 25, 2011 10:57 AM

    Hi,
    Please search SDN.. there are lots of posts for teh same.
    [http://wiki.sdn.sap.com/wiki/display/ABAP/FunctionModulerelatedonDate+calculations]

  • How to merge two date ranges

    Hi,
    I have following table. I want to merge date ranges if the dates are continuous and the value is same.I am using Oracle 10g.Please help.
    START_DATE END_DATE VALUE
    1/1/2008 12/31/2008 1234
    1/1/2009 12/31/2009 1234
    Sql statement output should be as follows:
    START_DATE END_DATE VALUE
    1/1/2008 12/31/2009 1234
    Thanks in advance.
    Edited by: user3898545 on Jan 27, 2010 7:44 PM

    Hi,
    user3898545 wrote:
    create table test_group(emp_id varchar2(5),
    start_date date,
    end_date date,
    value varchar2(10));
    insert into test_group(emp_id,start_date,end_date,VALUE) values ('E1','1-JAN-2008','31-DEC-2008','G1');start_date and end_date are DATEs; don't try to put VARCHAR2 values (such as '1-JAN-2008') into DATE columns. Use TO_DATE or DATE literals instead. The INSERT statements you posted may work on your system, but they won't necessarily work anywhere else. In particular, they don't work on my system. Post some sample data that anyone can use.
    ... I used following query to get the output 1/1/2009 - 12/31/2009 G2 when I ran for any date in 2010 or greater.There can be break in date ranges. Although query is giving the correct output which I am looking for I am looking for better performence.
    SELECT MAX (START_DATE)     AS START_DATE,MAX (END_DATE) AS END_DATE ,
    MAX(VALUE) KEEP (DENSE_RANK FIRST ORDER BY START_DATE DESC) GROUP_NUMBER
    FROM
    (WITH     GOT_GRP     AS
    (SELECT     TB_TEST_DATA.*,
         END_DATE - SUM (END_DATE + 1 - START_DATE) OVER ( PARTITION BY VALUE
                                            ORDER BY START_DATE) AS GRP
    FROM
    (SELECT HD.START_DATE,NVL(HD.END_DATE,'31-DEC-9999') "END_DATE",HD.VALUE
    FROM test_group HD
    WHERE HD.EMP_ID = 'E1'
    AND HD.START_DATE < NVL (HD.END_DATE, '31-DEC-9999')
    AND HD.END_DATE < :VDT_AS_OF_DATE
    ORDER BY EMP_ID,START_DATE) TB_TEST_DATA
    SELECT MIN (START_DATE)     AS START_DATE,MAX (END_DATE) AS END_DATE,VALUE
    FROM GOT_GRP
    GROUP BY VALUE,GRP
    ORDER BY START_DATE) CO_GRP;If you have new requirements, maybe you should start a new thread.
    What are your new requirements?
    When you say "There can be break in date ranges", do you mean grp plays no role in this new problem? In that case, you can save time and effort by not computing it.
    The following should produce the results you want from the sampe data given:
    WITH     got_r_num     AS
         SELECT     start_date, end_date, value
         ,     ROW_NUMBER () OVER ( ORDER BY start_date  DESC
                            ,           value       DESC
                           )     AS r_num
         FROM     test_group
         WHERE     end_date < TO_DATE ( :vdt_as_of_date
                           , 'DD-MON-YYYY'
    SELECT     start_date, end_date, value
    FROM     got_r_num
    WHERE     r_num     = 1
    ;

  • Figuring out the range of weeks betweeing two Dates?

    Hi all,
    Is there any hard and fast rule to calculate the number of days and/or weeks occupied between two date ranges?

    If you have Date date1, Date date2 and I assume date1 and date2 can belong to any year, I would do it in the basic way:
    int days =(int) Math.abs((date1.getTime() - date2.getTime()) / (24 * 60 * 3600 * 1000));
    int weeks = days / 7;
    That should be it.
    PC

  • Split dates into date range windows

    Hi,
    I have a peculiar requirement to create windows for different dates.
    For example I have two date ranges (two rows in the table column
    Start Date End Date
    01-Jan 28-Feb
    15-Jan 14-Feb (this starts between the previous date range i.e. 01-Jan to 28-Feb)
    I have to split dates in a way so that it creates different windows with start and end date i.e.
    Start Date End Date
    01-Jan 15-Jan (15Jan because it comes before 28 Feb)
    16-Jan 14-Feb ( 14Feb as it comes before 28 Feb)
    15-Feb 28-Feb
    Is there any sql function which can be used to achieve this? or any help you can provide? Thanks.
    -Salman

    Welcome to the forum!
    Unfortunately you posted to the wrong forum. This forum is for sql developer only.
    Repost you question in the SQL and PL/SQL forum and you will get help there.
    Please mark this question ANSWERED to people will follow up in the other forum.

  • Need help to join two tables using three joins, one of which is a (between) date range.

    I am trying to develop a query in MS Access 2010 to join two tables using three joins, one of which is a (between) date range. The tables are contained in Access. The reason
    the tables are contained in access because they are imported from different ODBC warehouses and the data is formatted for uniformity. I believe this cannot be developed using MS Visual Query Designer. I think writing a query in SQL would be suiting this project.
    ABCPART links to XYZPART. ABCSERIAL links to XYZSERIAL. ABCDATE links to (between) XYZDATE1 and ZYZDATE2.
    [ABCTABLE]
    ABCORDER
    ABCPART
    ABCSERIAL
    ABCDATE
    [ZYXTABLE]
    XYZORDER
    XYZPART
    XYZSERIAL
    XYZDATE1
    XYZDATE2

    Thank you for the looking at the post. The actual table names are rather ambiguous. I renamed them so it would make more sense. I will explain more and give the actual names. What I do not have is the actual data in the table. That is something I don't have
    on this computer. There are no "Null" fields in either of the tables. 
    This table has many orders (MSORDER) that need to match one order (GLORDER) in GLORDR. This is based on MSPART joined to GLPART, MSSERIAL joined to GLSERIAL, and MSOPNDATE joined if it falls between GLSTARTDATE and GLENDDATE.
    [MSORDR]
    MSORDER
    MSPART
    MSSERIAL
    MSOPNDATE
    11111111
    4444444
    55555
    2/4/2015
    22222222
    6666666
    11111
    1/6/2015
    33333333
    6666666
    11111
    3/5/2015
    This table has one order for every part number and every serial number.
    [GLORDR]
    GLORDER
    GLPART
    GLSERIAL
    GLSTARTDATE
    GLENDDATE
    ABC11111
    444444
    55555
    1/2/2015
    4/4/2015
    ABC22222
    666666
    11111
    1/5/2015
    4/10/2015
    AAA11111
    555555
    22222
    3/2/2015
    4/10/2015
    Post Query table
    GLORDER
    MSORDER
    GLSTARTDATE
    GLENDDATE
    MSOPNDATE
    ABC11111
    11111111
    1/2/2015
    4/4/2015
    2/4/2015
    ABC22222
    22222222
    1/5/2015
    4/10/2015
    1/6/2015
    ABC22222
    33333333
    1/5/2015
    4/10/2015
    3/5/2015
    This is the SQL minus the between date join.
    SELECT GLORDR.GLORDER, MSORDR.MSORDER, GLORDR.GLSTARTDATE, GLORDR.GLENDDATE, MSORDR.MSOPNDATE
    FROM GLORDR INNER JOIN MSORDR ON (GLORDR.GLSERIAL = MSORDR.MSSERIAL) AND (GLORDR.GLPART = MSORDR.MSPART);

  • Compare date ranges in two tables

    Hello,
    I'm trying to figure out a way of comparing the range of dates between two date columns from a single row in one table, to the range of dates from multiple rows in a related table.
    t1 (t1_id, absent_start_date, absent_stop_date)
    t2 (t2_id, t1_id, cover_start_date, cover_end_date)
    t2 has multiple rows for each row in t1
    I need to select rows from t1, in which the set of days for rows in t2 do not match the set of days between absent_start_date and absent_stop_date.
    For example, assume this row in t1:
    1, '10/08/2007', '15/08/2007'
    The set of days would be 10/08/07,11/08/07,12/08/07,13/08/07,14/08/07,15/08/07
    and these rows in t2
    1, 1, '10/08/2007', '11/08/2007'
    2, 1, '12/08/2007', '12/08/2007'
    3, 1, '14/08/2007', '15/08/2007'
    The set of days would be 10/08/07,11/08/07,12/08/07,14/08/07,15/08/07
    In this case, the related rows in t2 do not cover the same date range as the master row in t1, and so I need to select this row from t1 somehow.
    Any ideas anyone?
    Thanks.

    I am not sure about the exact output you want, but the next query will give you all gaps in the periods, so the presence of a row in this output may be enough?
    SQL> create table t1
      2  as
      3  select 1 t1_id, date '2007-08-10' absent_start_date, date '2007-08-15' absent_stop_date from dual union all
      4  select 2, date '2007-09-01', date '2007-09-10' from dual
      5  /
    Tabel is aangemaakt.
    SQL> create table t2
      2  as
      3  select 1 t2_id, 1 t1_id, date '2007-08-10' cover_start_date, date '2007-08-11' cover_stop_date from dual union all
      4  select 2, 1, date '2007-08-12', date '2007-08-12' from dual union all
      5  select 3, 1, date '2007-08-14', date '2007-08-15' from dual union all
      6  select 4, 2, date '2007-09-03', date '2007-09-05' from dual union all
      7  select 5, 2, date '2007-09-07', date '2007-09-08' from dual
      8  /
    Tabel is aangemaakt.
    SQL> select  *
      2    from ( select t2.t1_id
      3                , lag(t2.end_date+1,1,t1.absent_start_date) over (partition by t2.t1_id order by t2.start_date) gap_start_date
      4                , t2.start_date-1 gap_end_date
      5             from t1
      6                , ( select t1_id
      7                         , cover_start_date start_date
      8                         , cover_stop_date end_date
      9                      from t2
    10                     union all
    11                    select t1_id
    12                         , absent_stop_date+1
    13                         , absent_stop_date+1
    14                      from t1
    15                  ) t2
    16            where t1.t1_id = t2.t1_id
    17         )
    18   where gap_start_date <= gap_end_date
    19   order by t1_id
    20       , gap_start_date
    21  /
                                     T1_ID GAP_START_DATE      GAP_END_DATE
                                         1 13-08-2007 00:00:00 13-08-2007 00:00:00
                                         2 01-09-2007 00:00:00 02-09-2007 00:00:00
                                         2 06-09-2007 00:00:00 06-09-2007 00:00:00
                                         2 09-09-2007 00:00:00 10-09-2007 00:00:00
    4 rijen zijn geselecteerd.Regards,
    Rob.

  • Two Date Characteristics As An OR Condition For Date Range Input

    Hello,
    Here's the requirement.  The user inputs a date range.  In the query, we have two date characteristics.  If at least one of the date characteristics falls between the inputted date range, then the row should show up on the report.  This is essentially an OR condition.  How can this be done?
    Thanks!

    hi,
    just a tought... but worth a try.
    1) Create an 2 Formula variables with User Exit.(ZF1 & ZF2)
    2) These will be filled with data with SETP2(User Exit) from the user Entry Variable. One variable will have from date & the next one will have to date.
    3) Then create 2 more Formula variables (ZR1 & ZR2) this time with replacement path for the 2 date you have and the create a global Key Figure with If Condition.
    CKF's:
    (( ( ZR1 >= ZF1) AND ( ZR1 <= ZF2 ) ) * (your vales)
    repeat the same for the ZR2 also.
    Regards, Siva

  • Compare same date  showing up in two different ranges

    hi am comparing date with following requirement the value date transction must be within the Active date(>= greater than or equal) and inactive date(<= less than) date range,my problem is date is showing up in two diffirent ranges with the results of that am geting two error message
    lets say the date is
    transdate=2014-05-16
    activedate=24/APR/14
    inactivedate=25/APR/14
    s
    my code is
    try
                               String s_ActivDate = getValueFromTable("S", "EXCEPTION_NAME", "EXCEPTION_NAME", s_exceptionName, "EXCEPTION_NAME_DATE_ACTIVE");
                               String s_InactiveDate = getValueFromTable("S", "EXCEPTION_NAME", "EXCEPTION_NAME", s_exceptionName, "EXCEPTION_NAME_DATE_INACTIVE");  
                                System.out.println("Systemoutdateafer "+sDate);
                                System.out.println("Systemouts_InactiveDateafter "+s_InactiveDate);
                                System.out.println("Systemouts_ActivDateafter "+s_ActivDate);
                                System.out.println("Systemouts_ActivDateafter "+s_exceptionName);
                                //if (validate.validateException(s_exceptionName))
                                if(s_ActivDate != null)
                             if(s_InactiveDate != null)
                             if(!isActive(sDate,s_InactiveDate, s_ActivDate))    
                                    System.out.println("Systemoutdate "+sDate);
                                    System.out.println("Systemouts_InactiveDate "+s_InactiveDate);
                                    System.out.println("Systemouts_ActivDate "+s_ActivDate);
                                    System.out.println("Systemouts_ActivDate "+s_exceptionName);
                            } catch (SQLException ex)
                                 System.out.println("Systemouts_ActivDate "+s_exceptionName);
                                java.util.logging.Logger.getLogger(ValidateFile.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    public boolean isActive(String sValueDate, String sInactive, String sActive)
            Date date_active;
            Date date_inactive;
            System.out.println("Value Date "+sValueDate+" Active "+sActive+" InActive"+sInactive);
            try
                date_active = new SimpleDateFormat("yyyy-MM-dd").parse(sActive);
                Date dt_valueDate = new SimpleDateFormat("yyyy-MM-dd").parse(sValueDate);
                if(!isBlank(sInactive))
                    date_inactive = new SimpleDateFormat("yyyy-MM-dd").parse(sInactive);
                    if (dt_valueDate.compareTo(date_inactive) < 0 && dt_valueDate.compareTo(date_active) >= 0)
                        return true;
                }else
                    if (dt_valueDate.compareTo(date_active) >= 0)
                        return true;
            } catch (ParseException ex)
                java.util.logging.Logger.getLogger(Validate.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
            }catch(NullPointerException npe)
                return false;
            return false;

    Moderator Action:
    This is the third time you have posted this question.
    In your duplicate posting, you were shown where it would belong - a NetBeans forum space.
    https://community.oracle.com/thread/3560366
    ... and yet you continued to post it to an incorrect location.
    This triplicate post is locked (as are the others because they're off-topic for where you placed them)

  • How can I calculate the maximum number of days between two dates in a range of dates?

    I have a column of dates spanning the couse of a few months.  I would like to know if I can calculate the maximum number of days between each row and display the highest number.  I currently have another column that calculates the days betwen the rows and I am currently just looking at the totals and highlighting the highest period.
    Is this possible?  Any help or suggestions are appreciated.
    Thank you,
    Trevor

    This sounds totally possible,  Can you post a screen shot of your table to make responding more focused?  If you mean you want to:
    A) compute the difference (in days) between two date in the same row, then
    B) find the max duration (in days)
    Here is my take on this problem:
    D2 = C2-B2
    select D2 and fill down
    F1=MAX(D)
    to perform the conditional formatting (to highlight the max duration) select column D, then set up conditional formatting as shown in the 1st image

  • Date range query  problem  in report

    Hi all,
    I have created a report based on query and i want to put date range selection but query giving problem.
    If i am creating select list selection then it is working fine means it will display all records on the particular date.
    But what i need is that user will enter date range as creation_date1,creation_date2 and query should return all the records between these date range. i want to pass it by creating items, i created two items and passing creation_date range to display all records but not displaying and if not passing date then should take null as default and display all records
    Here is the query:
    /* Formatted on 2006/12/10 20:01 (Formatter Plus v4.8.0) */
    SELECT tsh."SR_HEADER_ID", tsh."SALES_DEPT_NUMBER", tsh."COUNTRY",
    tsh."LOCAL_REPORT_NUMBER", tsh."ISSUE_DATE", tsh."SUBJECT",
    tsh."MACHINE_SERIAL_NUMBER", tsh."MACHINE_TYPE", tsh."MACHINE_HOURS",
    tsh."STATUS"
    FROM "TRX_SR_HEADERS" tsh, "TRX_SR_PARTS" tsp
    WHERE (tsh.status LIKE :p23_status_sp OR tsh.status IS NULL)
    AND (tsh.machine_type LIKE :p23_machine_type_sp)
    AND ( tsh.machine_serial_number LIKE
    TO_CHAR (:p23_machine_serial_number_sp)
    OR tsh.machine_serial_number IS NULL
    AND ( TO_CHAR (tsh.failure_date, 'DD-MON-YY') LIKE
    TO_CHAR (:p23_failure_date_sp)
    OR TO_CHAR (tsh.failure_date, 'DD-MON-YY') IS NULL
    AND ( TO_CHAR (tsh.creation_date, 'DD-MON-YY')
    BETWEEN TO_CHAR (:p23_creation_date_sp)
    AND TO_CHAR (:p23_creation_date_sp1)
    OR TO_CHAR (tsh.creation_date, 'DD-MON-YY') IS NULL
    AND (tsh.issue_date LIKE :p23_date_of_issue_sp OR tsh.issue_date IS NULL)
    AND (tsh.country LIKE :p23_country_sp OR tsh.country IS NULL)
    AND ( tsh.local_report_number LIKE TO_CHAR (:p23_local_rep_num_sp)
    OR tsh.local_report_number IS NULL
    AND ( tsp.part_number LIKE TO_CHAR (:p23_part_number_sp)
    OR tsp.part_number IS NULL
    AND tsh.machine_type IN (
    SELECT DISTINCT machine_type
    FROM trx_sales_dept_machine_list
    WHERE sales_department_id IN (
    SELECT DISTINCT sales_department_id
    FROM trx_user_sales_department
    WHERE UPPER (user_name) =
    UPPER ('&APP_USER.'))
    AND SYSDATE >= valid_from)
    AND tsh.sr_header_id = tsp.sr_header_id
    can any one tell me wat is wroung in this query.
    Any other way to write this?
    Thank You,
    Amit

    Hi User....
    Here is some date range SQL that my teams uses with some success:
    For date columns that do not contain NULL values, try this (note the TRUNC, it might help with your "today" problem).
    The hard coded dates allow users to leave the FROM and TO dates blank and still get sensible results (ie a blank TO date field asks for all dates in the future.
    AND TRUNC(DATE_IN_DATABASE)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),:
    :P1_DATE_TO)
    For date columns that contain NULL values, try this (a little bit trickier):
    AND nvl(TRUNC(DATE_IN_DATABASE),
    decode( :P1_DATE_FROM,
    decode( :P1_DATE_TO,
    TO_DATE('30-DEC-3000'),
    NULL),
    NULL)
    BETWEEN
    decode( :P1_DATE_FROM,
    TO_DATE('01-JAN-1900'),
    :P1_DATE_FROM)
    AND
    decode( :P1_DATE_TO,
    TO_DATE('31-DEC-3000'),
    :P1_DATE_TO)
    Note the 30-DEC-3000 versus 31-DEC-3000. This trick returns the NULL dates when the FROM and TO date range items are both blank.
    I hope this helps.
    By the way, does anyone have a better way of doing this? The requirement is given a date column in a database and a FROM and a TO date item on a page,
    find all of the dates in the database between the FROM and TO dates. If the FROM date is blank, assume the user want all dates in the past (excluding NULL dates). If the TO date is blank, assume that the user wants all of the dates in the future (excluding NULL dates). If both FROM and TO dates are blank, return all of the dates in the databse (including NULL dates).
    Cheers,
    Patrick

  • How to create a date range in Web Application Designer

    I am using 3.1 version of Web App Designer.  I need to create a report with date ranges.  I can get one date to work but not two (I need a start date and end Date).  My Query has 0CALMONTH with a variable for Interval.  When I select it as a dropdown (??) in Web App Designer, I only get one date prompt in web app designer.
    Any suggestions??
    Thanks
    Kristen

    Hi Kristen,
    I'm sorry i'm not coming to solve your problem,but for the trouble I have had,and I want to create a date picker in Web Application Designer,so if you have solved the problem ,please email to me? [email protected] ,thx very much!
    best regards
    zegion chan

Maybe you are looking for