How to make a perfect validations between two dates..?

Hello,
i want to check this code with u christian pls,
DECLARE
V_MESSAGE NUMBER(2);
V_TO_DATE DATE ;
V_FROM_DATE DATE;
CURSOR MATERIALS IS
               SELECT MATERIAL_CODE,TO_DATE,FROM_DATE
               FROM PLN_TANK_MATERIALS
               WHERE TANK_CODE= :PLN_TANK_MATERIALS.TANK_CODE;
BEGIN
     FOR I IN MATERIALS
     LOOP
          IF (:FROM_DATE > I.FROM_DATE ) AND (:TO_DATE < I.TO_DATE ) THEN          
               V_MESSAGE := FUNC_MSG(1,'CASE 1');      
          RAISE FORM_TRIGGER_FAILURE;          
          ELSIF (:FROM_DATE > I.FROM_DATE ) AND (:TO_DATE > I.TO_DATE ) THEN     
               V_MESSAGE := FUNC_MSG(1,'CASE2');
          RAISE FORM_TRIGGER_FAILURE;
          ELSIF (:FROM_DATE < I.FROM_DATE ) AND (:TO_DATE > I.FROM_DATE ) THEN     
               V_MESSAGE := FUNC_MSG(1,'CASE3');
          RAISE FORM_TRIGGER_FAILURE;     
          ELSIF (:FROM_DATE < I.FROM_DATE ) AND (:TO_DATE > I.TO_DATE ) THEN     
               V_MESSAGE := FUNC_MSG(1,'CASE4');
                         RAISE FORM_TRIGGER_FAILURE;     
          ELSIF (:FROM_DATE = I.FROM_DATE)OR (:TO_DATE = I.TO_DATE )
                    OR (:FROM_DATE = I.TO_DATE)OR (:TO_DATE = I.FROM_DATE ) THEN     
                    V_MESSAGE := FUNC_MSG(1,'CASE5');
               RAISE FORM_TRIGGER_FAILURE;
          END IF;          
     END LOOP;          
END;
=========================================================
Regards ,
Abdetu..

i want to check this code with u christian plsnote that I am more Database PL/SQL Developer than Forms Developer...
also note that I am earning 20 Bucks/Code Review :D
But it would be nice to tell me your problem with the upper source, than maybe I can help u...
best regards
Christian

Similar Messages

  • How to calculate the hour difference between two dates?

    hi all,
    how to calculate the hour difference between two dates?
    eg i trying this...
    ((TO_DATE(TO_CHAR(GRNi.reference_date_4,'hh24:mi'),'hh24:mi') -
    TO_DATE(TO_CHAR(NVL(GRNi.reference_date_3,SYSDATE),'hh24:mi'),'hh24:mi'))*24)*60 Act_Hr
    Reg.
    AAK

    Hi
    To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
    select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
    trunc( sysdate-created ) "Dy",
    trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
    trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
    trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
    to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
    sysdate-created "Tdy",
    (sysdate-created)*24 "Thr",
    (sysdate-created)*24*60 "Tmi",
    (sysdate-created)*24*60*60 "Tsec"
    from all_users
    where rownum < 50
    HTH
    RangaReddy

  • 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

  • How to Calculate number of months between two dates

    Hi All,
       In one of the fomr developments, I have to calculate the
    Number of Days
    Number of Months ( Considering Leap Year) provided by the dates, end user enters in the form,
    After going thorugh some forum discussion, I have come to know about so many things which were not clear till now.
    I have gone through various forums too,  some one suggets to make use of FORM CALC and some other JAVA SCRIPT. But the logic i want to build in java script.
    The most interesting point is the DATE object is not getting created when i write  the below code
      var startDate = new DATE(oYear, oMonth, oDay);
    I am still not clear, that really the date object gets created in Adobe form If so the why the alert box is getting populated when i write below lines
    var oTemp = startDate.getFullYear();
    xfa.host.messagebox(oTemp);
    So, there are so many unclear things,
    If any one can help me by suggesting the approach and how to build the logic in the JavaScript I would be really thankful
    Regards
    PavanChand

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • How to calculate number of days between two date in Template design?

    Hello guys
    I have a situation where I have to create a template that returns data, and one of the thing of the existing report is that there is a column that is actually the number of days between start date and end date columns..
    So in template, how would I be able to do the same? I have start date and end date columns on the template, now when I created another column using expression like end date - start date and preview the template, I am getting errors saying :
    Caused by: oracle.xdo.parser.v2.XPathException: Cannot convert 03/31/2009 to number.
         at oracle.xdo.parser.v2.XSLStylesheet.flushErrors(XSLStylesheet.java:1534)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:521)
         at oracle.xdo.parser.v2.XSLStylesheet.execute(XSLStylesheet.java:489)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:271)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:155)
         at oracle.xdo.parser.v2.XSLProcessor.processXSL(XSLProcessor.java:192)
    Please advice
    Thanks

    Hi
    There is an extension function you can use, from the javadoc:
    date_diff
    public static long date_diff(java.lang.String format,
    java.lang.String fromDate,
    java.lang.String toDate,
    java.lang.String locStr,
    java.lang.String tzID)
    Method to get the difference between two dates in the given locale. The dates need to be in "yyyy-MM-dd" format. This function supports only Gregorian calendar.
    Parameters:
    format - the format to which the difference is required; allowed formats are y (for Year), m(for month), w(for week), d(for day), h(for hour), mi(for minute), s(for seconds) and ms(for milliseconds)
    fromDate - the first date
    toDate - the second date
    locStr - locale string -> lang-Territory
    tzID - timezone ID ->http://java.sun.com/j2se/1.4.2/docs/api/java/util/TimeZone.html
    Returns:
    the difference in dates in the desired format
    For example
    <?xdoxslt:date_diff(‘d’,’2009-09-14’, ‘2009-09-20’,’en-US’,1)?>
    give a result of 6
    You can substitute in columns for the dates, just remember the date format required.
    Regards
    Tim

  • How to count number of sundays between two dates

    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.

    Hi,
    ChakravarthyDBA wrote:
    Hi
    I want number of Sundays between two dates
    example
    number of Sundays count between '01-04-2013' and '30-04-2013' in one select query I have to include this as sub query in my select statement.Here's one way:
    SELECT       early_date
    ,       late_date
    ,       ( TRUNC (late_date + 1, 'IW')
           - TRUNC (early_date,        'IW')
           ) / 7       AS sundays
    FROM       table_x
    ;This does not depend on your NLS settings.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the statment above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}

  • How to Calculate Sum of Difference between two dates

    Hi,
    I'm using BI Publisher in Siebel CRM.
    In RTF template I have the following expression to calculate the Difference between dates
    <?xdoxslt:date_diff( 'd' , psfn:totext(CIRGSubmittedDate,"yyyy-MM-dd","MM/dd/yyyy"), psfn:totext(Done,"yyyy-MM-dd","MM/dd/yyyy"), $_XDOLOCALE, $_XDOTIMEZONE)?>
    The above expression works for me to calculate the dates.
    I need to calculate the Sum of all these dates for a Group.
    Want to know the Syntax for Sum function using Date_diff.
    Tried the following and didn't work.
    <?Sum(xdoxslt:date_diff( 'd' , psfn:totext(CIRGSubmittedDate,"yyyy-MM-dd","MM/dd/yyyy"), psfn:totext(Done,"yyyy-aMM-dd","MM/dd/yyyy"), $_XDOLOCALE, $_XDOTIMEZONE))?>
    Not sure what I'm doing wrong here...
    Anyone please help...
    Thanks
    PV

    Hi
    To break the diff between 2 dates into days, hours, minutes, sec -- you can use the following:
    select to_char( created, 'dd-mon-yyyy hh24:mi:ss' ),
    trunc( sysdate-created ) "Dy",
    trunc( mod( (sysdate-created)*24, 24 ) ) "Hr",
    trunc( mod( (sysdate-created)*24*60, 60 ) ) "Mi",
    trunc( mod( (sysdate-created)*24*60*60, 60 ) ) "Sec",
    to_char( sysdate, 'dd-mon-yyyy hh24:mi:ss' ),
    sysdate-created "Tdy",
    (sysdate-created)*24 "Thr",
    (sysdate-created)*24*60 "Tmi",
    (sysdate-created)*24*60*60 "Tsec"
    from all_users
    where rownum < 50
    HTH
    RangaReddy

  • How to get days , months , years between two dates with groovy

    I've a table that contains Start Date and End Date and I want to get the difference between then in this format 2 days , 1 moth , 1year
    Can I make this with Groovy
    I've added a transient attribute to a view object and make its value      return (EndDate) - (StartDate); but this returns the difference of days like 200 day
    I want it in this format 2 days , 1 moth , 1year

    AFAIK - You cannot do it in groovy.
    You can achieve the same using the transient variable approach.
    Create a VORowImpl Class for VO, and in the getter method of the transient variable - do the necessary logic and return the string as required in your use-case.
    Thanks,
    Navaneeth

  • How to export a weblogic application between two workshops

    i need to develop an application on two different computers. how to make the application portable between two workshops?
    Thanks.
    Denis

    Thanks for the response, but correct if I'm wrong: I just could use this option to export to war file if I had the source code and the project created under the eclipse IDE. If so, I'm not able to do that, since I haven't received any source code from this vendor. I have only received one windows installer which installs the war files inside the weblogic domain\server folder.
    I thought that there was an option under the weblogic administration console -> domain -> deployments which would let me export an existing application to a war file.
    So far, I've found one work around that is:
    * Run the windows installer of this app into a weblogic running on a windows box ;
    * Once the deployment is up, go into the PATH where this application is running inside the weblogic and generate a war file with all the existing files ;
    * Open the weblogic administration console of the linux box;
    * Import the war file ;
    Thanks,
    Davinod

  • Using pl/sql function for each day between two dates.

    Hi,
    create TABLE EMP(
    ID_EMP NUMBER,
    DT_FROM DATE,
    DT_TO DATE,
    CREATE_DATE DATE);
    into EMP(ID_EMP, DT_FROM, DT_TO, CREATE_DATE)
    Values(100, TO_DATE('07/01/2008 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('04/30/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'),TO_DATE('05/08/2009 14:11:21', 'MM/DD/YYYY HH24:MI:SS'));
    I have a function called  elig_pay_dates(date p_date), which returns the code for  person payment eligibility for a particular date. For paid dates it's 'P' and for unpaid dates it's 'N'.
    How can I check this function between two dates for each day. Example : 07/01/2008 to 04/30/2010.
    By using this function with select I needs to display the dates when there is a change in status.
    I am expecting data in following manner from above logic(this is example):
    07/01/2008 --- 07/01/2009 ---'P'
    07/02/2009 -- 07/25/2009 ----'N'
    07/26/2009 -- 01/01/2010 ---'P'
    01/02/2010 -- 01/13/2010 --'N'
    01/14/2010 -- 01/18/2010 --'P'
    01/19/2010 -- 04/30/2010 -- 'N'
    I thought of looping for each day date but that seems to be expensive for online application. Is there any way that I can achieve this requirement with sql query ?
    Thanks for your help,

    Certainly not the best way to code the requirement, but it does achieve the result you are looking for in a fairly quick time
    create or replace
    function test_ret_paid_unpaid (p_date in date)
    return varchar2
    is
      v_ret     varchar2(1);
    begin
      if ( (p_date between to_date('07/02/2009', 'MM/DD/YYYY') and to_date('07/25/2009', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/02/2010', 'MM/DD/YYYY') and to_date('01/13/2010', 'MM/DD/YYYY') ) or
           (p_date between to_date('01/19/2010', 'MM/DD/YYYY') and to_date('04/30/2010', 'MM/DD/YYYY') )
        then v_ret := 'N';
      else
        v_ret := 'Y';
      end if;
      return v_ret;
    end;
    Wrote file afiedt.buf
      1  with get_paid_unpaid as
      2  (
      3    select dt_from start_date, dt_to end_date, dt_from + level - 1 curr_date, test_ret_paid_unpaid(dt_from + level - 1) paid_unpaid,
      4           row_number() over (order by dt_from + level - 1) rn_start,
      5           row_number() over (order by dt_from + level - 1 desc) rn_end
      6      from test_emp
      7    connect by level <= dt_to - dt_from + 1
      8  ),
      9  get_stop_date as
    10  (
    11  select start_date init_date, end_date, curr_date, paid_unpaid,
    12         case when paid_unpaid != lag(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    13          then curr_date
    14          else null
    15         end start_date,
    16         case when paid_unpaid != lead(paid_unpaid) over (order by curr_date) or rn_start = 1 or rn_end = 1
    17          then curr_date
    18          else null
    19         end stop_date
    20    from get_paid_unpaid
    21  )
    22  select period, paid_unpaid
    23    from (
    24  select init_date, curr_date, start_date, end_date, stop_date,
    25         case when paid_unpaid = lead(paid_unpaid) over (order by curr_date)
    26                then nvl(start_date, init_date) || ' - ' || lead(stop_date, 1, end_date) over (order by curr_date)
    27              else null
    28         end period,
    29         paid_unpaid
    30    from get_stop_date
    31   where stop_date is not null or start_date is not null
    32         )
    33*  where period is not null
    12:06:10 SQL> /
    PERIOD                                             PAID_UNPAID
    01-JUL-08 - 01-JUL-09                              Y
    02-JUL-09 - 25-JUL-09                              N
    26-JUL-09 - 01-JAN-10                              Y
    02-JAN-10 - 13-JAN-10                              N
    14-JAN-10 - 18-JAN-10                              Y
    19-JAN-10 - 30-APR-10                              N
    6 rows selected.
    Elapsed: 00:00:00.35

  • Gap Between Two Dates

    Can Anyone tell me how to find out the gap between two dates. Specifically Without counting Saturday and Sunday.

    corlettk wrote:
    <intercession>
    Has anyone written a DateMath class?... it would be handy... the amount (and ugliness) of the code required to do elementary date mathematics with the raw Calendar is appaling.<recess>
    Isn't Java 7 supposed to cure all this headache?
    </recess>

  • Java code to get the difference between two dates in days

    Hi ppl,
    I need to write a user defined function to get the difference between two date nodes, in days.Please help me out
    regards,
    Prashanth

    Hi,
    have a look at those two:
    (How do I calculate the difference between two dates?)
    http://joda-time.sourceforge.net/faq.html
    Calculating the Difference Between Two Datetime Stamps
    http://www.xmission.com/~goodhill/dates/deltaDates.html
    Get difference in days
    http://javaalmanac.com/egs/java.util/CompDates.html
    Regards,
    michal

  • How can I make a server differ between two or more clients?

    How can I make a server differ between two or more clients?
    The clients can connect and talk to the server fine, but how can I make the server talk to one, two or all clients? i.e. what would be a good way to implement this?
    Currently, the server listens for connections like this:
    while (listening) {
    try {
    new ServerThread(this, serverSocket.accept()).start();
    I guess one way would be to add the ServerThreads to a Hashtable with the client ID as key, and then get the ServerThread with the proper client ID, but this seems unnecessary complicated. Any ideas?

    Complicated was perhaps the wrong word, I should have
    written something like it doesn't "feel" right. Or is
    this a common and good way to solve communication
    between a server and multiple clients?Thats pretty much how I do it. I normally use an array or ArrayList of Sockets instead of HashTable, with [0] being the first player etc.... Then you can communicate with exactly who you want. If you want to send bytes to all of them, just send the same thing to each socket individually (or is there a better way to do this?).

  • 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;

  • How to SIMPLY add audio crossfade between two clips ?

    Tried to make a simple cut edit for tv news.
    How to add an audio crossfade between two clips to soften transition ?
    Detach audio, then create audio only scenario, then add transition ? Unusable.
    When importing 8 tracks from Xdcam HD, how do you choose wich audio track to add your transition to ?
    Also, impossible to re-export to Xdcam disk on the field.
    This piece of software is simply unusable in real life pro conditions. Some very nice features, globally a disaster.

    First thank you all for taking time to reply.
    I found these solutions myself but for me these are only workaround.
    In Fcp7, you just had to drag and drop dissolve transition to clips junctions TO AUDIO TRACK ONLY. Very quick and simple. In Fcpx, it is very time consuming if you want to add audio crossfade to every clip junction in a full project. That's really not a software evolution in my opinion...
    I think "easy transitions to audio tracks only" has to be implemented in next version.
    Thanks again !

Maybe you are looking for