Search between two dates

Hi,
I have a fields start_date(Literal Date) and end date (Literal Date) in my MDM table.
Could any one give me a clue how to search values between these two dates from java program to this type of columns.
Waiting for reply.

Hi,
Following is a snippet of code for searching a range on a date/time field in an MDM repository.
In the following code, the table we are searching on is called "Products", and has two fields: "Part Number" and "Update Date" which is the date field. We will search for all products with "Update Date" between 2006-1-1 and 2006-1-31. (Remember in Java that MONTHS are from 0-11, and NOT 1-12).
============= START OF CODE =================
                    // Create a ResultSetDefinition
                    ResultSetDefinition rsd = new ResultSetDefinition("Products");
                    rsd.AddField("Part Number");
                    rsd.AddField("Update Date");
                    // Create a Search object
                    Search search = new Search("Products");
                    FreeFormTableParameter fftp = search.GetParameters().NewFreeFormTableParameter("Products");
                    FreeFormParameterField ffpf = new FreeFormParameterField("Update Date");
                    FreeFormParameter ffp = new FreeFormParameter();
                    ffpf.Add(new DateTimeParameter(2006, 0, 1, 0, 0, 0, 0, FreeFormParameter.GreaterThanOrEqualToSearchType));
                    ffpf.Add(new DateTimeParameter(2006, 0, 31, 0, 0, 0, 0, FreeFormParameter.LessThanOrEqualToSearchType));
                    ffpf.SetSearchOperator(FreeFormParameterField.SEARCH_OPERATOR_AND);
                    fftp.Add(ffpf);
                    // Get the results using the search                    
                    A2iResultSet rs = catalog.GetResultSet(search, rsd, "Part Number", true, 0);
                    System.out.println("Num found = " + rs.GetRecordCount());
============= END OF CODE =================
Hope this helps,
Walter

Similar Messages

  • Search between Two date Error

    Hi,
    i have create report using to table i have take search option in that report now i want to display report between two dates
    How to put Between Date Quary in search option in where Clause .
    My code is
    select      CRM_SALES_DEALs.id,
             "CRM_SALES_CUSTOMERS"."CUSTOMER_NAME" as "CUSTOMER_NAME",
          "CRM_SALES_SALESREPS"."REP_LAST_NAME"||', '||
          "CRM_SALES_SALESREPS"."REP_FIRST_NAME" as "REP_NAME",
          "CRM_SALES_DEALS"."DEAL_NAME" as "DEAL_NAME",
          "CRM_SALES_DEALS"."EMAIL" as "EMAIL",
          "CRM_SALES_DEALS"."DEAL_CLOSE_DATE" as "DEAL_CLOSE_DATE",
          "CRM_SALES_DEALS"."DEAL_AMOUNT" as "DEAL_AMOUNT",
          "CRM_SALES_DEALS"."DEAL_PROBABILITY" as "DEAL_PROBABILITY",
          "CRM_SALES_DEAL_STATUS_CODES"."STATUS_CODE" as "STATUS_CODE" ,
             "CRM_SALES_DEALS"."DATE_OF_QUARY" as "DATE_OF_QUARY",
             "CRM_SALES_DEALS"."DEAL_SOURCE" as "DEAL_SOURCE",
             "CRM_SALES_DEALS"."DEAL_AMOUNT" *
             "CRM_SALES_DEALS"."DEAL_PROBABILITY" / 100 weighted_forecast,
    (select count(*) from CRM_SALES_DEAL_products where deal_id = "CRM_SALES_DEALS".id) products,
    nvl("CRM_SALES_DEALS".updated_on,"CRM_SALES_DEALS".created_on) last_changed,
    t.territory_name,
    CRM_SALES_DEALS.qtr, "CRM_SALES_DEALS"."CONTACT_NAME" as "CONTACT_NAME",
    "CRM_SALES_DEALS"."ACTIVE_FLAG" as "ACTIVE_FLAG"
    from     
    "CRM_SALES_SALESREPS",
    "CRM_SALES_DEAL_STATUS_CODES" ,
    "CRM_SALES_CUSTOMERS",
    "CRM_SALES_DEALS",
    CRM_SALES_territories t
    where  
    CRM_SALES_customers.customer_territory_id = t.id(+) and
    "CRM_SALES_DEALS"."CUSTOMER_ID"="CRM_SALES_CUSTOMERS"."ID"(+)
    and      "CRM_SALES_DEALS"."DEAL_STATUS_CODE_ID"="CRM_SALES_DEAL_STATUS_CODES"."ID"(+)
    and      "CRM_SALES_DEALS"."SALESREP_ID_01"="CRM_SALES_SALESREPS"."ID"(+) and "CRM_SALES_DEALS"."ACTIVE_FLAG" ='Y' and (:p1_find is null or instr(upper("CRM_SALES_CUSTOMERS"."CUSTOMER_NAME"),upper(:p1_find))>0 or instr(upper("CRM_SALES_DEALS"."DEAL_NAME"),upper(:p1_find))>0 or
    instr(upper("CRM_SALES_SALESREPS"."REP_FIRST_NAME"||' '||"CRM_SALES_SALESREPS"."REP_LAST_NAME"),upper(:p1_find))>0)
    and
    (nvl(:P1_TERRITORY,0) = 0 or t.id= :P1_TERRITORY)
    and
    (nvl(:P1_ACCOUNT,0) = 0 or "CRM_SALES_CUSTOMERS".id = :P1_ACCOUNT)
    and
    (nvl(:P1_QUARTER,'0') = '0' or CRM_SALES_deals.qtr = :P1_QUARTER)
    and
    *("CRM_SALES_DEALS".created_on between :P1_CREATE_DATE and :P1_END_DATE ) >0 and*                                          *Here I have put Quary*
    instr(upper("CRM_SALES_DEALS"."CREATED_ON"),upper(nvl(:P1_CREATE_DATE,"CRM_SALES_DEALS"."CREATED_ON"))) > 0
    and
    nvl(DEAL_PROBABILITY,10) between nvl(:P1_MINIMUM_PROBABILITY,0) and nvl(:P1_MAXIMUM_PROBABILITY,100) AND
    (nvl(:P1_LEAD_SOURCE,'0') = '0' or CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Show me Error Command not Properly Ended
    How can i search Between two date In Search option.
    Thanks

    I'm guessing that this is Jay???
    Please heed my numerous previous comments regarding formatting and those horrible full table aliases and upper case, double quoted names... Grrr...
    Anyway, try this...
    SELECT   CRM_SALES_DEALs.id,
             CRM_SALES_CUSTOMERS.CUSTOMER_NAME AS CUSTOMER_NAME,
                CRM_SALES_SALESREPS.REP_LAST_NAME
             || ', '
             || CRM_SALES_SALESREPS.REP_FIRST_NAME
                AS REP_NAME,
             CRM_SALES_DEALS.DEAL_NAME AS DEAL_NAME,
             CRM_SALES_DEALS.EMAIL AS EMAIL,
             CRM_SALES_DEALS.DEAL_CLOSE_DATE AS DEAL_CLOSE_DATE,
             CRM_SALES_DEALS.DEAL_AMOUNT AS DEAL_AMOUNT,
             CRM_SALES_DEALS.DEAL_PROBABILITY AS DEAL_PROBABILITY,
             CRM_SALES_DEAL_STATUS_CODES.STATUS_CODE AS STATUS_CODE,
             CRM_SALES_DEALS.DATE_OF_QUARY AS DATE_OF_QUARY,
             CRM_SALES_DEALS.DEAL_SOURCE AS DEAL_SOURCE,
             CRM_SALES_DEALS.DEAL_AMOUNT * CRM_SALES_DEALS.DEAL_PROBABILITY / 100
                weighted_forecast,
             (SELECT   COUNT ( * )
                FROM   CRM_SALES_DEAL_products
               WHERE   deal_id = CRM_SALES_DEALS.id)
                products,
             NVL (CRM_SALES_DEALS.updated_on, CRM_SALES_DEALS.created_on)
                last_changed,
             t.territory_name,
             CRM_SALES_DEALS.qtr,
             CRM_SALES_DEALS.CONTACT_NAME AS CONTACT_NAME,
             CRM_SALES_DEALS.ACTIVE_FLAG AS ACTIVE_FLAG
      FROM   CRM_SALES_SALESREPS,
             CRM_SALES_DEAL_STATUS_CODES,
             CRM_SALES_CUSTOMERS,
             CRM_SALES_DEALS,
             CRM_SALES_territories t
    WHERE   CRM_SALES_customers.customer_territory_id = t.id(+)
             AND CRM_SALES_DEALS.CUSTOMER_ID = CRM_SALES_CUSTOMERS.ID(+)
             AND CRM_SALES_DEALS.DEAL_STATUS_CODE_ID =
                   CRM_SALES_DEAL_STATUS_CODES.ID(+)
             AND CRM_SALES_DEALS.SALESREP_ID_01 = CRM_SALES_SALESREPS.ID(+)
             AND CRM_SALES_DEALS.ACTIVE_FLAG = 'Y'
             AND (:p1_find IS NULL
                  OR INSTR (UPPER (CRM_SALES_CUSTOMERS.CUSTOMER_NAME),
                            UPPER (:p1_find)) > 0
                  OR INSTR (UPPER (CRM_SALES_DEALS.DEAL_NAME), UPPER (:p1_find)) >
                       0
                  OR INSTR (
                       UPPER(   CRM_SALES_SALESREPS.REP_FIRST_NAME
                             || ' '
                             || CRM_SALES_SALESREPS.REP_LAST_NAME),
                       UPPER (:p1_find)
                    ) > 0)
             AND (NVL (:P1_TERRITORY, 0) = 0 OR t.id = :P1_TERRITORY)
             AND (NVL (:P1_ACCOUNT, 0) = 0
                  OR CRM_SALES_CUSTOMERS.id = :P1_ACCOUNT)
             AND (NVL (:P1_QUARTER, '0') = '0'
                  OR CRM_SALES_deals.qtr = :P1_QUARTER)
             AND CRM_SALES_DEALS.created_on BETWEEN :P1_CREATE_DATE
                                                 AND  :P1_END_DATE
             AND INSTR (
                   UPPER (CRM_SALES_DEALS.CREATED_ON),
                   UPPER (NVL (:P1_CREATE_DATE, CRM_SALES_DEALS.CREATED_ON))
                ) > 0
             AND NVL (DEAL_PROBABILITY, 10) BETWEEN NVL (:P1_MINIMUM_PROBABILITY,
                                                         0)
                                                AND  NVL (
                                                        :P1_MAXIMUM_PROBABILITY,
                                                        100
             AND (NVL (:P1_LEAD_SOURCE, '0') = '0'
                  OR CRM_SALES_DEALS.DEAL_SOURCE = :P1_LEAD_SOURCE)Cheers
    Ben

  • How to make search between two dates accept null not obligatory search proplem

    Hi guys when i search record between two dates it works ok success but you must enter date from and dateto first to  to make search
    i will show what i need from this example
    I need to search dynamic by 4 textbox
    1-datefrom
    2-dateto
    3-EmployeeNo
    4-EmployeeName
    but search i need must be dynamic meaning
    if i enter employee no only give me employee no found in database
    if i enter employee name give me employees found with this name using like
    if i enter all 4 text box null and enter button search get all data
    but i have proplem in this query when i need to search by click search button
    i must write date from and date to firstly then write employee no or employee name if i need to search
    so that i need to search by employee no alone or employee name alone without using date from and date to
    And if i search without using datefrom and dateto it give me message error 'string wasnot recognized as valid datetime"
    my stored procedure and code as following :
    ALTER proc [dbo].[CollectsearchData]
    @StartDate datetime,
    @EndDate datetime,
    @EmployeeID  NVARCHAR(50),
    @EmployeeName  nvarchar(50)
    as
    Begin
    Declare @SQLQuery as nvarchar(2000)
    SET @SQLQuery ='SELECT * from ViewEmployeeTest Where (1=1)'
    If (@StartDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate >= '''+ Cast(@StartDate as varchar(100))+''')'
    If (@EndDate is not NULL)
    Set @SQLQuery = @SQLQuery + ' And (joindate <= '''+ Cast(@EndDate as varchar(100))+''')' 
    If @EmployeeID <>''
    Set @SQLQuery = @SQLQuery + 'And (EmployeeID = '+ @EmployeeID+') '
    If @EmployeeName Is Not Null
    Set @SQLQuery = @SQLQuery + ' AND (DriverName LIKE
    ''%'+@EmployeeName+'%'') '
    Print @sqlQuery
    Exec (@SQLQuery) 
    End
    Function using
    public DataTable SearchDataA(string ConnectionString,string EmployeeNo,string EmployeeName, DateTime StartDate, DateTime EndDate)
    SqlConnection con = new SqlConnection(ConnectionString);
    SqlCommand cmd = new SqlCommand();
    cmd.Connection = con;
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.CommandText = "CollectsearchData";//work
    cmd.Parameters.Add("@StartDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EndDate", SqlDbType.DateTime);
    cmd.Parameters.Add("@EmployeeID", SqlDbType.NVarChar, 50);
    cmd.Parameters.Add("@EmployeeName", SqlDbType.NVarChar, 50);
    cmd.Parameters["@StartDate"].Value = StartDate;
    cmd.Parameters["@EndDate"].Value = EndDate;
    cmd.Parameters["@EmployeeID"].Value = EmployeeNo;
    cmd.Parameters["@EmployeeName"].Value = EmployeeName;
    SqlDataAdapter da = new SqlDataAdapter();
    da.SelectCommand = cmd;
    DataSet ds = new DataSet();
    da.Fill(ds);
    DataTable dt = ds.Tables[0];
    return dt;
    interface button search
     try
    CultureInfo ukCulture = new CultureInfo("en-GB");             
    FleetManagment.Fleet fleet = new FleetManagment.Fleet();
    DataTable Table = fleet.SearchDataA("Data Source=" + value1 + ";Initial Catalog=" + value2 + ";User ID=" + value3 + ";Password=" + value4 + "",textBox3.Text,textBox4.Text, DateTime.Parse(textBox1.Text,
    ukCulture.DateTimeFormat), Convert.ToDateTime(textBox2.Text, ukCulture.DateTimeFormat));
    dataGridView1.DataSource = Table;
    dataGridView1.Refresh();
    catch (Exception ex)
    MessageBox.Show(ex + "error");

    Yes, the below code should not be passed any value: (I am not sure of the syntax in .NET,Sorry) 
    --If startdate len is 0 - do not assign this value
    cmd.Parameters["@StartDate"].Value = StartDate;
    --If endate len is 0 - do not assign this value
    cmd.Parameters["@EndDate"].Value = EndDate;

  • Query to search between two specific dates and time period

    Hi,
    Need a query to search between two particular dates and time period
    Like i want to search table having one date field .
    Suppose the date range is '01-JUL-06' and '01-AUG-06' and time frame
    is 23:00:00 to 08:00:00
    i.e i want to search between dates 01 july to 01 aug and also within the time frame i.e 23:00 to 08:00 hrs only

    The general principle is
    SELECT * FROM your_table
    WHERE some_date BEWTEEN to_date('01-JUL-06') and to_date('01-AUG-06' )+0.99999
    AND  ( some_date <= trunc(some_date)+8/24
               OR  some_date >= trunc(some_date)+23/24 )
    /Cheers, APC

  • Difference between two dates

    Hi
    I have two date fields in the ODS..Both are characterists
    1. Requested delivery date
    2. Actual shipment end date.
    I would like to create a calculated KF  field for the difference between two dates in a query.
    How can I accomplish it?
    Regards

    You have to make Expiration data as nav attribute and create a formula variable then only this date can be used in calculations.
    refer this How to...for the same
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/72f4a790-0201-0010-5b89-a42a32223ffc
    later you can try to calculate difference between dates!
    Re: calculating the difference between two dates
    Please search in forum with 'difference between two dates'.You will find lots of good posts on this issue!
    hope this helps
    Regards

  • Count days between two dates without weekend

    Hi,
    I need a solution in query or another thread, that returns the count of days between two dates without consider weekend (saturday and sunday) , I have the columns of type Date, and the return need in format of hours in one column hh:mm:ss and days in another column.
    Regards
    Jonas

    Hi and welcome to the forum.
    Keep in mind that you can do a search on this forum.
    Your question has been asked before.
    Some other pointers:
    http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:185012348071

  • How to query the number of working days between two dates

    I'm looking for a solution to calculate the number of <i>working</i> days between two dates that I can use in a formated search. 
    Calculating the total number of days is pretty straight forward but does anyone know how to take into account the settings in the HLD1 (Holiday Dates) table?

    Hi Eric,
    If you are purely looking to exclude holidays defined in the HLD1 table, then you should be able to do it with the following query
    NOTE: The following query is an example using OINV table and the fields DOCDATE and DOCDUEDATE for a Particular DOCNUM  'xxx'
    If you planning to use within the SAP module then replace DOCDATE and DOCDUEDATE with dynamic field references $[$x.x.x]
    SELECT DATEDIFF(DAY,T0.DOCDATE,T0.DOCDUEDATE)-
    (SELECT COUNT(STRDATE) FROM HLD1 WHERE STRDATE >= T0.DOCDATE AND STRDATE <= T0.DOCDUEDATE)
    FROM OINV T0
    WHERE T0.DOCNUM = xxx
    Best Wishes
    Suda

  • To find difference between two dates

    Hi all,
    I am new to this forum and oracle.
    I want to get the difference between two dates. My query is as below...
    sqlserver_utilities.datediff('YY', startdate,enddate)
    I want the difference in year.
    Please help me. It's really urgent.
    Thanks in advance.
    Regards,
    Inam

    Select to_char(enddate,'YY') - to_char(startdate,'YY') fromPLEASE don't do that. There are so many things wrong with it...
    for example:
    1). Why are you subtracting character data types?
    2). What if the start date is 1999 and the end date is 2000? Do you expect to get a difference of -1?
    3). What if the start date is 1 Jan 2000 and the end date is 31 Dec 2000? Do you expect to get 0 instead of 1 or .997?
    4). Why would you convert dates to something else when they are inherently subtractable.
    5). There are obvious points in the OP's "specification" that are vague - the best thing (after telling them to search, of course since this has been answered a million times already) would be to try to clarify the spec.
    John

  • Removing Weekends in between two dates

    Hi,
    I need to get the number of days in between two dates excluding the weekends.
    Does anyone know how to do this?
    Thanks.

    Here's a search of the forum for "difference dates". At least the first three questions are identical to yours.
    http://search.java.sun.com/Search/java?col=javafrm&qp=%2Bforum%3A31&qt=difference+dates&x=12&y=10

  • Working days between two date fields and Changing Factory Calendar

    Hi,
    I have to calculate working days between two date fields excluding the weekends and public holidays for Switzerland.
    I have written the routine using factory calender and its working fine except for two problems now:
    1. If any one of the date field is empty then teh rsult should be zero.
    2. And the below code is working from 1996 but my cleints wants it to work for years before 1996 as well.
    I also tried to change the Start date in SCAL for factory calendar but it says enter values between 1995 to 2020.
    I am new to ABAP. Please help me how i can achieve these for below code.
    DATA: IT_HOLIDAYS type TABLE OF ISCAL_DAY,
          IS_HOLIDAYS TYPE ISCAL_DAY.
    DATA: T_DATE TYPE SY-DATUM,
          P_DATE TYPE SY-DATUM.
    DATA : X_DATE(4) TYPE C.
    DATA: CNT TYPE I.
    REFRESH : IT_HOLIDAYS.
    CLEAR : IT_HOLIDAYS.
    T_DATE = SOURCE_FIELDS-/BIC/ZCCCHP812.
    P_DATE = SOURCE_FIELDS-/BIC/ZCCCHP810.
    CALL FUNCTION 'HOLIDAY_GET'
    EXPORTING
    HOLIDAY_CALENDAR = 'CH'
    FACTORY_CALENDAR = 'CH'
    DATE_FROM = P_DATE
    DATE_TO   = T_DATE
    TABLES
    HOLIDAYS = IT_HOLIDAYS
    EXCEPTIONS
    FACTORY_CALENDAR_NOT_FOUND = 1
    HOLIDAY_CALENDAR_NOT_FOUND = 2
    DATE_HAS_INVALID_FORMAT = 3
    DATE_INCONSISTENCY = 4
    OTHERS = 5.
    DESCRIBE TABLE IT_HOLIDAYS LINES CNT.
    X_DATE = T_DATE - P_DATE - CNT.
    RESULT = X_DATE.
    Please help
    Regards
    Zabina
    Edited by: Syed786 on Nov 2, 2011 9:15 AM

    Hi Zabina,
    Try this function module  'DURATION_DETERMINE'.
    Give the factory calendar and unit as DAY
    With regards,
    Rajesh

  • How to calculate the month difference between two date char. in Query?

    Customers would like to see how many months passed between two date type of characteristics (e.g., the month difference between the current date and the scheduled delivery date in the record) and put the result into the column as KF. 
    We would have to grab the fiscal year/period kind of value and then do the subtraction, e.g., if the current date value is 2/28/2008 and the scheduled delivery date value in the record is 12/01/2007, the correct result should be 2 month difference between these two date values, but could someone here give us the technical light on how to make this happen in query design?
    Thanks and we will give you reward points for the correct anwsers!

    Hi Kevin,
    The Badi is RSR_OLAP_BADI.
    You can create an implementation using Transaction  SE18.
    The implementation is per cube and is defined in the filters.
    In the Implementation you have the following methods :
    1. Define : Here you will provide the Keyfigure you need as a virtual one.
    2. Initilialize : Any Init Function you want to do.
    3. Compute. This is called per datarecord and here you can cimpute your value.
    Hope this helps.
    Pralay Ahluwalia

  • As to the data type of the data type of the difference between two date type of datas

    Hi,
    I have a question about the data type of the difference between two date type of datas.
    There are two date type of datas as:
    SSHIPMENTS.RECEIVEDATETIME
    SSHIPMENTS.PROMISEDATETIME
    I try to use the following SQL Script in Oracle SQL*Plus as:
    SELECT CASE
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:00:00.000' THEN 'OnTime'
    WHEN (SSHIPMENTS.RECEIVEDATETIME - SSHIPMENTS.PROMISEDATETIME) < '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    The error message of "Invalid Number" for the '000 01:30:00.000' happens.
    I don't know if the data type of the interval is wrong.
    Many Thanks,
    Cathy

    SELECT CASE
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss')) < '010000' THEN 'OnTime'
    WHEN (to_char(SSHIPMENTS.RECEIVEDATETIME,'hhmiss') - to_char(SSHIPMENTS.PROMISEDATETIME,'hh24miss'))< '000 01:30:00.000' THEN '60-89 Minutes'
    ELSE '3+ Hours'
    END
    FROM SSHIPMENTS;
    just try it out..

  • No of Fridays in between two date

    Hi all
    What is the Qucikest and easy way to retreive the NO of fridyas in betwen two dates
    Thanks & Regards
    Vivek

    vivekvm wrote:
    Hi all
    What is the Qucikest and easy way to retreive the NO of fridyas in betwen two dates
    Make sure you test the boundary conditions for any solution you get.
    Have you defined exactly what you mean by "in between two dates", for example. do you want to count the end points if one, or both, of them is a friday ?
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk
    To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
    "Science is more than a body of knowledge; it is a way of thinking"
    Carl Sagan                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How can i get report between two dates?

    Hi
    how can i get report between two dates?
    for example i want get reports between 20/4/2002 & 27/4/2002.
    my table has date column and i can get first date( exam : .... where date:=a and/or ....i don't know this part)
    thanks alot.
    Regards
    The Oracle Reports Team
    http://otn.oracle.com/

    where exam_date between :from_date and :to_date
    from_date and to_date are user_parameter

  • Difference between two date ,according to office time.

    hi,
    How can I get diffrence between two date.
    If I select from-date  20-03-2012 09:30AM and to-date 20-03-2012 06:30PM then output should be 1 day(as it is office time from 09:30 AM TO 06:30 PM).
    ACCORDINGLY If I select from-date  20-03-2012 09:30AM and to-date 21-03-2012 02:00PM then output should be 1.5 day
    select 24*(to_date(:P2_TO_DATE,'DD-MM-YYYY HH:MIPM') - to_date(:P2_FROM_DATE,'DD-MM-YYYY HH:MIPM'))"date" from dual;

    Hello Shirish,
    WITH dates AS(
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('20-03-2012 06:30PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('20-03-2012 04:15PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 09:30AM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 12:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('21-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('22-03-2012 02:00PM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
        UNION ALL
        SELECT  TO_DATE ('20-03-2012 04:30PM', 'DD-MM-YYYY HH:MIPM') AS start_date
               ,TO_DATE ('22-03-2012 10:00AM', 'DD-MM-YYYY HH:MIPM') AS end_date
        FROM    dual
    ,times as(
    SELECT  start_date
           ,end_date
           ,TRUNC (end_date - start_date) days
           ,MOD (end_date - start_date,1) hours
           ,(start_date - 9.5/24 - TRUNC (start_date))*24 offset_start
           ,(end_date - 9.5/24 - TRUNC (end_date))*24 offset_end
           ,(end_date - 9.5/24 - TRUNC (end_date))*24
            - (start_date - 9.5/24 - TRUNC (start_date))*24 offset_diff
    FROM    dates
    SELECT  TO_CHAR(start_date, 'DD-MM-YYYY HH:MIPM') AS start_date
           ,TO_CHAR(end_date, 'DD-MM-YYYY HH:MIPM') AS end_date
           ,days
           ,ROUND(offset_start,2) offset_start
           ,ROUND(offset_end,2) offset_end
           ,ROUND(offset_diff,2) offset_diff
           ,CASE WHEN offset_diff > 4 THEN
                days + 1
            WHEN offset_diff > 0 THEN
                days + 0.5
            WHEN offset_diff = 0 THEN
                days
            WHEN offset_diff + 9 > 4 THEN
                days + 1
            ELSE
                days + 0.5
            END computed_days
    FROM  timesThe first step (subquery times) computes the full days and the difference between start_date and end_date, compared to the beginning of the office ours (9.5 /24)
    The second step takes the days and according to the possible values of the difference adds a half or a full day.
    Regards
    Marcus
    Edited by: Marwim on 19.03.2012 11:23
    CASE offset_diff = 0

Maybe you are looking for