How to compare 2 dates

Please, tell me how to compare between the field two Nina in the date format?
There is a script in this format, which takes the beginning and end of treatment records.
--=========
SELECT (SELECT MIN (start_TIME)
OF APP_HISTORY HPA
WHERE APH. APPLICATION_FK IN
(SELECT APP.ID
OF THE APP APPLICATION
WHERE APP. APPID = "D4TEST4NMA-19'.
)
) start_app,.
(SELECT MAX (end_TIME)
OF APP_HISTORY HPA
WHERE APH. APPLICATION_FK IN
(SELECT APP.ID
OF THE APP APPLICATION
WHERE APP. APPID = "D4TEST4NMA-19'.
)
) end_app
DOUBLE;
--=========

To calculate how much time between the beginning and the end of the treatment required in order to to deal with in the time format "dd.mm.yyyy hh24:mi:ss.

Tips

1 you have a relational database. Relational databases address tables, lines and columns. No fields. There are no fields in any RDBMS
2 the unit of a DATE column is a DAY
3 you can add and subtract two DATE columns, the result will be in DAYS
4 allows you to convert that number to any other unit by making a date has 24 * 60 minutes and 24 * 60 * 60 seconds.

------------
Sybrand Bakker
Senior Oracle DBA

Tags: Database

Similar Questions

  • How to compare two dates and find exactly

    How to compare two dates and find the exact age of the person, no one could be an age of child 2 days or a month, or other.

    I'd really appreciate if someone help o

    Concerning

    After spending 2 hours, I go out with a solution by myself, how ever the function can be customize to check if the user enters date right.

    function findAge(subjectName,fromdate, todate) {
        console.log("findAge(fromdate, todate) is called now "+subjectName+"-->"+fromdate+"-->"+todate);
        if(todate) todate= new Date(todate);
        else todate= new Date();
    
        var age= [], fromdate= new Date(fromdate),
        y= [todate.getFullYear(), fromdate.getFullYear()],
        ydiff= y[0]-y[1],
        m= [todate.getMonth(), fromdate.getMonth()],
        mdiff= m[0]-m[1],
        d= [todate.getDate(), fromdate.getDate()],
        ddiff= d[0]-d[1];
    
        if(mdiff < 0 || (mdiff=== 0 && ddiff<0))--ydiff;
        if(mdiff<0) mdiff+= 11;
        if(ddiff<0){
            fromdate.setMonth(m[1]+1, 0);
            ddiff= fromdate.getDate()-d[1]+d[0];
            --mdiff;
        }
        if(ydiff> 0) age.push(ydiff+ ' year'+(ydiff> 1? 's ':' '));
        if(mdiff> 0) age.push(mdiff+ ' month'+(mdiff> 1? 's':''));
        if(ddiff> 0) age.push(ddiff+ ' day'+(ddiff> 1? 's':''));
        if(age.length>1) age.splice(age.length-1,0,' and ');
        console.log("===============================");
        console.log("Subject age is = "+age.join(''));
        console.log(" age Day = "+ddiff);
        console.log(" age Month = "+mdiff);
        console.log(" age Year = "+ydiff);
        console.log("===============================");
        var subjectAGE =  age.join('');
    
    }
    

    peardox Thanks for the reply

  • How to compare two dates and times in BPEL?

    Hi all
    I need to compare two dates and times in a switch activity, but could not find any function for her.

    My switch like this activity:

    case Date1 > date2:
    do something;
    otherwise:
    do something;

    He is not such a function in 'The functions of Date' and can not find this function to xpath.

    IBE, there is no function for a period of time to make (less one date of another?...) If this return to the data compare question).

    Thank you.

    Hello

    Logic function as more/less function can be used to compare two dates so that same comapring two numbers.

    Ex: If your variable reception contains two pieces of data such as date1 and date2, then you can use format in condition switch below.

    XpathXpression (date1) > XpathXpression (date2)

    hope this will help you.

  • How to compare a Date with the current year data and member of period on FIX

    Hi experts,

    I have a Sun project that each Member is a project (P01, P02,...)
    and account IMGs who stores the information of each project (name, Start date, finished...)
    Finished Date member is of data type Date

    So how can write an IF condition below in order to be able to compare the end Date of the project with the members of the current year and period on FIX
    DIFFICULTY (@Descendants (Projects), Descendants (year-round), Descendants ("year Total")...)
    IF (@CURRMBR (Period)-> @CURRMBR (Year) < Project > - FinishedDate)
    Do something...
    On the other
    Do something


    Please help me on this. Sorry for my bad grammar. Please ask if there is something not clear

    Thank you very much
    Van Huy.

    Published by: Van Huy on 29 January 2013 01:14

    Published by: Van Huy on 29 January 2013 02:24

    Published by: Van Huy on 29 January 2013 02:25

    Published by: Van Huy on 29 January 2013 18:04

    Here's what I did. Post for which may later cover

    VAR FM; / * End of month of the project.
    VAR EXERCISE; / * Year of the project terminated * /.
    VAR CM; / * Capture the current month on FIX declarations * /.
    VAR CY; / * Capture current year on FIX declarations * /.

    DIFFICULTY (@RELATIVE ('year', 0), @RELATIVE ('period', 0), @IDescendants ("core projects")...)

    FY = @ROUND ('TGHT'-> ' NA contract "-> 'FY06'-> ' NA period" / 10000, 0);
    FM = @MOD (@ROUND ('TGHT'-> ' NA contract "-> 'FY06'-> ' NA period" / 100, 0), 100);
    / * For FY13 back 13... */
    CY = @JgetDoubleFromString (@CONCATENATE ('20', @SUBSTRING (@NAME (@CURRMBRRANGE (year, Lev, 0, 0, 0)), 2)));
    / * Value CM set based on perceived period on the DIFFICULTY of statement * /.
    IF (@ISMBR ("Jan"))
    CM = 1;
    ELSE IF (@ISMBR ("February"))
    CM = 2;
    .....
    ELSE IF (@ISMBR ("Dec"))
    CM = 12;
    ENDIF

    IF (CY< fy="" or="" (="" cy="=" fy="" and="" cm=""><>
    Do something...
    ON THE OTHER
    Do something...
    ENDIF
    ENDFIX

    Published by: Van Huy on 19 February 2013 23:10

    Published by: Van Huy on February 20, 2013 19:46

  • How to compare two dates

    Hello

    I have two columns (start date and end date) data type date in my page and both are optional.

    I need a validation on these date columns,

    End date should not be greater than the Start Date.

    This validation must be triggered once I click the button apply.

    Pseudocode:

    If (endate > startdate)
    {
    raise form_trigger_failure;
    }


    Can anyone suggest how/where to apply the code, if possible, please indicate the code of the sample.

    Thank you
    Mahesh

    Hello

    Please refer to the code below, and try to apply in the same way. It should solve your problem

    import java.util.Date;

    / * In LICS * /.

    If (pageContext.getParameter (Apply)! = null) / * ID of the button apply * /.
    {
    String strStartDate = pageContext.getParameter ("SearchStartDate");
    String strEndDate = pageContext.getParameter ("SearchEndDate");
    System.out.println ("Start Date:" + strStartDate);
    System.out.println ("End Date:" + strEndDate);
    If ((null! = strStartDate) & (null! = strEndDate) & (""! ")) = strStartDate) & (""! ") = strEndDate))
    {
    Day dtStartDate = new Date (strStartDate);
    Day dtEndDate = new Date (strEndDate);
    System.out.println ("Start Date:" + dtStartDate);
    System.out.println ("End Date:" + dtEndDate);

    If (dtEndDate.getTime)<>
    {
    System.out.println ("inside the date validation and error messages jet");
    OAException dateMessage = new OAException ("XXNCV", "XXNCV_Date_Message", null, null, OAException.ERROR),
    oapagecontext.putDialogMessage (dateMessage);
    oapagecontext.setForwardURLToCurrentPage (null
    true
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO
    OAWebBeanConstants.IGNORE_MESSAGES);
    }
    }

    Thank you best regards &,.
    REDA Papdeja

    Published by: RajPapdeja on June 15, 2010 13:12

  • How to compare, present value: block.text_item with the value of data

    Hello
    Could you please tell me
    How to compare the current value: block.text_item with the corresponding database column value.
    I use form 10g

    It has block and there is a text element in this block.
    When I run the form and query the block (in a table), the: block.text_item show me any value it in the database.
    Now I add value in the: block.text_item to the existing value.

    now
    the: block.text_item contains the old + new added value
    While
    the database table contains the value 'old '.

    Now, with a click of button, I want to know what value I added

    Please can you me, is it possible without writing a select query?

    Hello

    Now, with a click of button, I want to know what value I added

    So you're saying always user will bring added value to the existing value. Because it will fail in a case. Let's say that
    Database value is = ABCD
    The user opens the form and he took the D and write E and now value is ABCE and length is always the same 4. There is therefore no need to add.

    In any case, you can know that the value of database at run time, there is a property for the element called DATABASE_VALUE. She gives the value that is in the database while you run the form before save. and you can use it like that...

    Trigger = WHEN-MOUSE-DOUBLE-CLICK on item level
    DECLARE
      vItemValue DATATYPE; -- Set the data type according to your desired field.
      vValueAdded DATATYPE; -- Set the data type according to your desired field.
    BEGIN
      vItemValue:=GET_ITEM_PROPERTY('ITEM_NAME',DATABASE_VALUE);  -- It will return you the database value in vItemValue variable.
      IF LENGTH(vItemValue)>LENGTH(:FORM_ITEM_NAME) THEN  -- It mean something change or added
        vValueAdded:=SUBSTR(:FORM_ITEM_NAME,LENGTH(vItemValue)+1);
        MESSAGE('Added value is : '||vValueAdded);  -- It will show you the added value.
      END IF;
      -- now suppose you want to show the old and new value in message not the added one
      -- Then no need of IF condition. You can just use message like this
      -- And i would prefer to use like this way
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
      MESSAGE('Old Value : '||vItemValue||'  New Value - '||:FORM_ITEM_NAME);
    END;
    

    Hope that's clear.

    -Clément

  • Flash memory card data verification, how to compare folders/files in Labview?

    Hi, I need to check and verify the data that is stored in a Flash memory card, sience I got a good card Flash contant, I hv to write a VI to check suspected bad Flash card data against Flash memory good data card, I use the output folder list folder list function is compared with the data of constant string that contains the name of folder and files (since I know the content good map).

    Is there any other method to compare the data/files/folders, such as the CRC check for data... all all tracks, ideas? Please help me.

    Thanks in advance,

    Ravikumar C

    The range of the file IO has a function to perform an MD5 on a file.  If you want to detect the validity of a set of files, what happens if you had a list of files and md5s and then conducted an audit to see if all the files have the MD5 expected.  Of course, you will need to take a line of well known file-based and MD5s.

  • How to compare table 1 d

    I am reading data inport hexagonal form and save it in the table to compare the data with 0100800000D 0...  How can I make hexagonal constant array to store the 010080000D 0... and then compare it with the table that store data of inport... (In fact this works as a control)

    Or there is another good option


  • How to read the data in a device connected to the usb port

    Is there a class or object, or the piece of code in Java that is comparable to the PDQComm32.ocx and the mscomm32.ocx used in VB6? I need to know how to read the data of a device plugged into the usb port of the BBerry. Is it possible to use the BB to read data from a device via a usb cable?

    I'm new in Java and I'm looking for the opportunity to write a project to read the data in a device with this program that can turn on a BB instead of on a pc.

    Thank you

    Did you watch net.rim.device.api.system.USBPort?

    That's what the doc says:

    Provides access to the USB port of the device.

    Avoid using this class in applications, as it is not portable. On the contrary, if you need to access the USB port, use factory CLDC Connector to serve a connection.

    Rab

  • By comparing the Dates in a group of data (different lines)

    I have a requirement where I have to compare dates in a dataset for each employee.  The data looks like this:

    WITH test_data AS

    (SELECT the '1' AS pk, '5900' AS emp_id, '5' AS rec_id, to_date('01-JAN-2014') AS rec_date FROM dual

    UNION ALL

    SELECT '2', '5900', '5', to_date('01-FEB-2014') FROM dual

    UNION ALL

    SELECT '3', '5900', '5', to_date('01-MAR-2014') FROM dual

    UNION ALL

    SELECT '4', '5900', '5', to_date('01-JAN-2014') FROM dual

    UNION ALL

    SELECT '5', '5900', '6', to_date('06-JAN-2014') FROM dual

    UNION ALL

    SELECT '6', '5900', '6', NULL FROM dual

    UNION ALL

    SELECT '7', '5900', '6', to_date('01-JUL-2014') FROM dual

    UNION ALL

    SELECT '8', '5900', '7', to_date('29-JAN-2014') FROM dual

    UNION ALL

    SELECT '9', '5900', '7', to_date('29-SEP-2014') FROM dual

    UNION ALL

    SELECT '10', '5900', '7', to_date('01-OCT-2014') FROM dual

    UNION ALL

    SELECT '11', '8595', '5', to_date('01-SEP-2014') FROM dual

    UNION ALL

    SELECT '12', '8595', '6', to_date('05-SEP-2014') FROM dual

    UNION ALL

    SELECT '13', '8595', '7', to_date('30-SEP-2014') FROM dual

    UNION ALL

    SELECT '14', '8595', '7', NULL FROM dual

    )

    REC_ID column is composed of 3 different types of records, which must satisfy this requirement:

    REC_ID 5 acts as point of departure, and REC_ID 6 must have a REC_DATE within 7 days of REC_ID 5 REC_ID 7 must have a REC_DATE within 30 days of REC_ID 6.

    • If the requirements are any record in REC_ID 5 acts like zero day or the starting point;
    • Any record in REC_ID 6 must be within 7 days of the date of REC_ID 5;
    • Any record in REC_ID 7 must be within 30 days from 6 REC_ID.

    My results:

    Expected results - satisfactory records

    EMP_ID

    DATE_1

    DATE_2

    DATE_3

    5900

    1 January 14

    6 January 14

    29 January 14

    8595

    1 sep-14

    5 sep-14

    30 sep-14

    I don't know how to compare dates in a dataset that are on different lines.  I thought using self-joins, query using the window as rank (), factoring functions, but I'm stuck pretty quickly.

    I appreciate all help.  Thank you!

    Aqua

    Hello

    AquaNX4 wrote:

    WOW odie_63: it would be a blessing if I was... but unfortunately, I'm on 10 gr 2.  That would have been great!

    Frank Kulash:

    I'm stuck (mentally) to the fact that there is an amount without discernment of records in the base table for each type of REC_ID.

    Some employees have 5 folders for REC_ID, 10 REC_ID 6 and 7 for REC_ID 7, which leaves me confused in how many self-joins I should do, or if it is at all possible.  I did a lot of arithmetic of dates with the data on the same line and certain ranks () functions for data residing on different lines, but this 1 seems to confuse me...

    I ran 1 self-join as below to see what it looks like and it confused me even more because I know the timestamp of the arithmetic in where clause still will not produce data as I want...  I am now trying another way...

    SELECT td2.rec_id,

    TD2.emp_id,

    TD2.rec_date

    Of

    test_data2 td2

    LEFT JOIN test_data td1 ON td1.emp_id = td2.emp_id


    It's a good start.

    You want an inner join, however, not an outer join, not you?  Outer join means "include td2 lines if they have data in the corresponding TD1".  If I understand the question, you are only interested in cases where it is matching data.

    Here's a way to do it:

    WITH joined_data AS

    (

    SELECT d5.emp_id

    d5.rec_date LIKE date_1

    d6.rec_date AS date_2

    d7.rec_date AS date_3

    ROW_NUMBER () OVER (PARTITION BY d5.emp_id

    ORDER BY d5.rec_date

    d6.rec_date

    d7.rec_date

    ) AS r_num

    OF test_data d5

    JOIN test_data d6 ON d6.emp_id = d5.emp_id

    AND d6.rec_date > = d5.rec_date

    AND d6.rec_date<= d5.rec_date="" +="">

    JOIN test_data d7 ON d7.emp_id = d6.emp_id

    AND d7.rec_date > = d6.rec_date

    AND d7.rec_date<= d6.rec_date="" +="">

    WHERE d5.rec_id = '5'

    AND d6.rec_id = "6"

    AND d7.rec_id = "7"

    )

    SELECT emp_id, date_1, date_2, date_3

    OF joined_data

    WHERE r_num = 1

    ;

    The subquery joined_data find all combinations of rows that meet the criteria.  We want to only 1 line by emp_id, so I used ROW_NUMBER assign unique r_nums (starting at 1) to all lines with the same emp_id and then, in the main query, rejected all but the 1st row.

    Knapen had a good idea, but it won't work for all cases.  There may be situations where the only combination of rows that meet the criteria does not use the MIN or MAX of dates of one (or several).

  • How to compare premises, iSCSI and storage NFS for VMware ESXi 5 with IO Analyzer?

    Hello

    I have 2 hosts ESXi 5.0 with a few virtual machines running. I would compare the IO throughput for my local storage, iSCSI and NFS vmware storage store. Can someone point me to the right direction? I read the documents and tutorials, but I'm not sure how to compare tests from these 3 options.

    I have a need to compare the following storage options.

    Local disk on the ESX host

    iSCSI on QNAP NAS device

    iSCSI on EMC e 3100

    NFS on QNAP NAS device

    NFS on EMC e 3100

    IOmeter seems to be good tool based on reading, but still not clear where to make changes to pass tests of storage to another.

    Thanks in advance,

    Sam

    If you use IO monitor, then you must simply vmotion the VMS to the data store for the device you want to test, and then run the test (and Records results).  Can vmotion for the following data store and repeat.

  • How do I export data from one day to backup disk.

    Hi all

    Here we have a requirement like, we need to download the data from one day to the external drive and we must compire the exported data and the data in the table.
    I googled and I have discovered that using expdp command we can export the table content, but my Question is how do I export data from one day. My table having 2 years of data and I need download the data of only one day.

    expdp scott/tiger@db10g tables = EMP, DEPT = TEST_DIR dumpfile = EMP_DEPT.dmp expdpEMP_DEPT.log = logfile directory

    Can someone tell me how to download data from one day to the table & compare data exported with the data in the table. (I know both exported and data of the table data will be the same that we are downloading data of the actual table, but for tests, I need to know how to compare).


    Thank you
    Sree

    However, I do not understand the scenario but here is a way to compare:
    (1) change the name of the table newly created in another name
    (2) import the exported file once again

    you will have the same data in both tables

  • How to find the data in two tables are the same?

    Hi people,

    Suppose we have table emp01, have 10 records and create another emp02 as table

    create the table emp02 in select * from emp01;

    now both the table has the same data.

    How to find a 'data' in the two tables are the same?

    Hello

    SELECT *
    FROM emp01
    MINUS
    SELECT *
    FROM emp02
    UNION
    SELECT *
    FROM emp02
    MINUS
    SELECT *
    FROM emp01
    

    You can also compare resultset hash to select * in emp01 and select * from emp02 by using dbms_sqlhash.

    Best regards
    Nikolai

  • Compare a date with the date system

    Hello

    I use the script (that I found in this forum) in below in order to obtain a date of datefield1, add a year and give the date of datefield2.

    It works very well.

    Kai var = util.scand ("yyyy-mm-dd", this.rawValue);
    var sFullYear = oDate.getFullYear ();
    var sMonth = oDate.getMonth ();
    sDate var = oDate.getDate ();
    Datefield2.FormattedValue = util.printd ("JJ", new Date ((sFullYear+1), sMonth, sDate));
    Datefield2.RawValue = Datefield2.formattedvalue;

    But now I would compare the new date (David [added a year]) with the date current system (cDate).

    Does anyone have an idea how to compare dates? The result should change color as below.

    If (David < cDate) {}
    Datefield2.fontcolor = "255,0,0";
    }

    Thank you very much.

    Kind regards

    ra_be

    Try to use the Date of Javascript object:

    var myDate = new Date();
    myDate.setFullYear (2010,0,14);
    var today = new Date();

    If (myDate > today)
    {
    Alert ("the date is before January 14, 2010");
    }
    on the other
    {
    Alert ("today, it is after January 14, 2010");
    }

    If this does not work, try the analysis on the month, day and year, and then do a comparison on all of them (without forgetting to convert strings of months an integer. For example if you store the release date: February 2, 2009, February goes to 2).

    Then your comparison would look like:

    if(myYear == sysYear) {}

    if(myMonth == sysMonth) {}

    if(myDay == sysDay) {}

    days are equal

    }

    Else if (myDay<>

    myDay is before sysDay
    }

    else {}

    myDay is after sysDay

    }

    }

    }

    essentially to follow this same logic for comparisons of month and year and it should work as well.  It would be certainly cleaner and much easier using this Date however (http://www.w3schools.com/jsref/jsref_obj_date.asp)

  • How to compare the time slices in 15 minutes?

    Using Flash 8 Pro AS2

    Have an animation to play once at the first visit to the site, regardless of the number of pages visited within the site. Then start over when to return to site.

    I thought that SharedObject would work for this. I managed to do it run at the same time to visit the site and the value of the shared object. Problem is that the animation NEVER play again because the shared object is never removed.

    Is there a way to put so it was like a session then that would solve this easy. I don't know how to do if there is a way.

    So I decided to make the swf file to check the page reload or if come back once again, site 15 minutes has elapsed. If so, update the time in being shared right now and the animation playback.

    Problem is that I have NO idea how compare the time set in the shared object at the moment to check whether or not the 15 minutes has passed.

    I tried different things, but the comparison, at the end of the hour, goes into the negative numbers. I am here minutes passing between saved time and the current time. Nothing else for a few minutes.

    I'm not a mathematical genius or understand all the stuff that I see out there in the tutorials and code examples, when it comes to the date and the time of calculation.

    I need to be. Delete the shared object to the closure or the site navigation browser.
    OR
    Check if 15 minutes has passed then at day time in the shared object and read the animation

    I'm just stuck in the calculation of time to determine whether or not the 15 minutes passed.

    What happens if they return to the site of the days or even weeks? My minutes of follow-up test has no meaning when entering hours and days or even weeks or months. Of course, my approach does NOT work.

    Any help would be great. Don't forget to Flash 8 pro and AS2 NOT AS3 or flash 9.


    Thank you

    I don't know how you look at the time, but if you create a DATE object:

    var today: Date = new Date(); It's actually an object of date and time.

    So, if you compare this date and time with an earlier date object and the object of time by using the Date method getTime() as follows

    Now.getTime () - previousDate.getTime () = the number of milliseconds that have elapsed between the "previousDate' and 'now '. If the difference is > 15 * 60 * 1000, 15 minutes.

Maybe you are looking for