Compare two date columns

Hello

I want to compare two columns of dates in a table.

Here, I wish to confirm that the two values are the same in each record.


Hope that make sense



See you soon

Sexy

Hi, Vanessa,.

If d1 and d2 are the two DATE columns:

SELECT     *     -- or list whatever columns you want to see
FROM     table_x
WHERE     d1 != d2
;

Displays all the lines where they are declared, but not the same thing.

If you want to include the lines where one of them is null, but the other is not:

SELECT     *     -- or list whatever columsn\ you want to see
FROM     table_x
WHERE     LNNVL (d1 = d2)
;

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 calculate the time difference in the two date columns time.

    Hi Obiee Experts,

    I came back new requirement on obiee 10g.


    I have two date columns in my table time, data as below.

    StartDate: 18/03/2012-04:40:51

    Closing date: 18/03/2012-04:50:55

    I want to the output as below (Jet lag).

    output
    04:40:51 (less)-04:50:55 = 00:10:04

    I hope you understand my requirement in OBIEE.

    Note: I want to show above the output values in another State for OBIEE10g column.

    Please share me your valuable contributions. Urgent appeals.

    Thank you
    Satya

    Hi Satya,

    Here's another solution. You can try the formula below as it is:

    Cast (floor (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.))) SESS_BEG, '-SNP_SESSION '. SESS_END) / 3600) as char). ':' ||
    Cast (floor (mod (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.)))) SESS_BEG, '-SNP_SESSION '. ((SESS_END), 3600) / 60) as char). ':' ||
    Cast (mod (TIMESTAMPDIFF (sql_tsi_second, '-SNP_SESSION '.))) SESS_BEG, '-SNP_SESSION '. SESS_END), 60) as char)

    I would like to know if that's what you're looking for.

    Thank you

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

  • by comparing the two date columns

    I want to compare two values of the column of the same table. Both the date and time part. but I would like to compare with only the date portion. I want these files where two dates are not same. but it includes a part of the time in the comparison with the following query.
    select * from reporttransactions a,  reporttransactions b  
    where trunc ( to_date(a.TRANSACTION_DATE, 'DD/MM/YYYY' )) <> trunc (to_date(b.TRANSACTION_CREATION_DATE,'DD/MM/YYYY' ))
    any suggestion

    I think it's true,

    When: WHERE TRUNC (A.TRANSACTION_DATE) = TRUNC (B.TRANSACTION_CREATION_DATE)

    223605062     3247     0     0     -     215     1     215     8     8     0     215PKI     01/09/2012     01/09/2012
    223605056     5733     0     0     -     131     1     131     9     9     0     131RAS     01/09/2012     01/09/2012
    223605050     4568     0     0     -     132     1     132     5     5     0     132FSH     01/09/2012     01/09/2012
    223604993     1623     0     0     -     176     1     176     8     8     0     176TCL     01/09/2012     01/09/2012
    

    When: WHERE TRUNC (A.TRANSACTION_DATE)! = TRUNC (B.TRANSACTION_CREATION_DATE);

    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    225833757     9113     0     0     -     161     1     161     3     3     0     161CBE     16/09/2012     16/09/2012
    

    What's wrong?

  • Stored procedure to compare two data tables

    Hello

    I want to have a stored procedure that will compare two tables data (only one column) and remove the line that is not present in the second table.

    For example.,.
    I have 2 tables called Table1 and Table2, that have the same column called ID (PK).
    Data in Table1 are 1,2,3 and data into Table2 are 1.3. When the stored procedure is running, it must compare the ID column in Table1 to ID column in Table2 and since '2' is not there in Table2, I want to remove this line from Table1.

    Thanks in advance.

    delete from table1
    where does not exist (select 1 from table2 where table2.id = table1.my_field)
    ;

  • EL: Compare two dates

    JDeveloper 12.1.3

    I want to make sure component based on the comparison of two date, something like:

    < af:outputText value = "(Expired)" id = "ot3" inlineStyle = "color: Red; '" make-weight: bold; »

    rendering = "#{now > links.}" EndDate.inputValue} "/ >"

    "now" is java.util.Date from registered managed bean (thin layer of ADF/JSF) while the EndDate above origin of VO (EO-based) and is default java.sql.Timestamp so cannot quite compare the two.

    What is the recommended way to do this?

    I was able to create a bean:

    public class NowTimestamp {}

    Timestamp private now;

    public void setNow (Timestamp now) {}

    This.now = now;

    }

    public Timestamp getNow() {}

    java.util.Date date = new java.util.Date ();

    return of new Timestamp (date.getTime ());

    }

    }

    then use rendered = "#{datebean.now > links.}" EndDate.inputValue}"but read while it is not recommended to have sql. Timestamp in the user interface.

    First rule of the ADF: stop your instincts and start to put your logic in the transient VO attributes, rather than on the safeguarding of the beans.

    To do this, you must create a transitional type VO Boolean attribute, allows to call this attribute "expired".

    In ViewRowImpl.getExpired, you will have:

    public Boolean getExpired() {}

    Since a long time now = System.currentTimeinMillis ();

    Timestamp nowTS = new Timestamp (now);

    {if (getEndDate () .after (nowTS))}

    Returns false;

    }

    Returns true;

    }

    rendering = "#{bindings." Expired.inputValue} "/ >"

  • Compare two dates

    Hi, I tried the below question when comparing the two dates, but gives the wrong result

    start date is 01/12/2005 amd stop iss date 07/03/2007

    with t as)

    Select to_date('12/1/2005','mm/dd/yyyy') start_date, to_Date('3/7/2007','mm/dd/yyyy') double stop_date)

    Select * from t

    where to_char(trunc(t.start_date),'mm/dd/yyyy') > to_char(trunc(t.stop_date),'mm/dd/yyyy') or

    TO_CHAR(t.start_date,'mm/dd/yyyy hh: mm: SS AM') > to_char(t.stop_date,'mm/dd/yyyy hh: mm: ss AM')

    Please correct me where I am doing wrong

    Thank you

    You compare characters not dates. Remove to_char where clause.

    with t as)

    Select to_date('12/1/2005','mm/dd/yyyy') start_date, to_Date('3/7/2007','mm/dd/yyyy') double stop_date)

    Select * from t

    When trunc (t.start_date) > trunc (t.stop_date) or

    t.start_date > t.stop_date

  • need to compare two dates in IDM

    I have a requireemnt where I need to compare two fields that are dates. If the first date is greater than the other, then perform a logic 1 other execute logic 2.
    If anyone is implemeneted scenario so please let me know.

    Thank you
    Kalpana.

    Try below I have implemented similar

    Date value = date get of your method
    SimpleDateFormat formatter = new SimpleDateFormat ("yyyy-MM-DD hh: mm :"); ")
              
    try {}
    Date startDate = formatter.parse ("1971-01-08 00:00:01");
    If (value.before (startDate))
    Return BCFConstants.SUCCESS;
    on the other
    No matter what

    In my example, a date has been set. Thus, I have stated here. You can get both the date in the method and put a similar logic

    -nayan

  • 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

  • compare two data

    Hi I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I use the version of labView 13. Please suggest Best looks meyssoun Senapati

    supriyasenapati wrote:

    Mr President, my message itself does not clearly displayed. I don't know why it happened. My real message was like that-

    I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I'm using labView version 13.Thanks.

    Probably you have pasted in HTML Mode and other things betweeen <> had stripped.

    To reproduce, in paragraph above was pasted below while the editing window has been implemented in HTML, this is clearly what has happened!

    Mr President, my message itself does not clearly displayed. I don't know why it happened. My real message was like that--I want to compare two numeric values is entered by the CNC, and b. If a = b then I want to see 'RAM', if a and b, then I want to see 'JADU' in the indicator.in of the façade. I'm using labView version 13.Thanks.

  • Is there an easy way to compare two null columns?

    I need to compare a large number of columns between the records from two tables for data conversion. I really need a comparison that returns true if: 1) the two columns are null; or (2) the two columns are not null and equal. I want him to return false if: 3) a column is set to null and the other isn't. or (4) the two columns are not null and are not equal. I'm trying to find the records which are not exact matches.

    I found the documentation for oracle-www.m-base.org/Sounds.html on the SYS_OP_MAP_NONNULL function that would do what I want, but I don't want to use it because it's an undocumented feature and my code will be in production for a period of time.

    I don't want to use a construction like this for each column that I compare:
    (
         (
              a.col is null
              and b.col is null
         )
         or (
              a.col = b.col
         )
    )
    Also, I don't know about the NVL function, but I compare columns that are entered by users, and I'm not comfortable, because these values could actually exist in the data of all NULL values.

    Hello

    Kiran says:
    where 1 = decode (coalesce(a.col,b.col), null, 1, decode (a.col, b.col, 1, 0))

    Or

    WHERE   1 = DECODE (a.col, b.col, 1)
    
  • compare two data texfields

    I have two text fields in a form namely Data1 and Data2. Entering database2, I want apex to check or validate the field so that it will warn or disable the textfield if number is greater than number of Data1 textfield. How to implement this using the javascript function? Is there another method? Annie

    Hi Tony,.

    Oops my bad, thanks for the correction.

    One approach could be to

    Make sure that your action 'Execute Javascript Code' that you have p_Data2 in the field "Page of elements to return. You need this so that the value that you set in the javascript code will return to the element on the page.

    $v ('P_Data2') syntax will work

    if (parseInt($v('P_Data2')) > parseInt($v('P_Data1'))) {
        if (confirm($v('P_Data2') + " is greater than" + $v('P_Data2'))) {
            doSubmit('SUBMIT');
        }
    } else {
        alert($v('P_Data2') + " is not greater" + $v('P_Data2'));
    }
    

    Thank you

    Benjamin.

  • Difference between two date columns

    Dear professionals,
    How to get different between two columsn (sati_do-sati_od) in format HH24:
    select to_char(sati_od,'hh24:mi') "hh:mi format", 
    to_char(sati_do,'hh24:mi') "orginal_value_col2",
    sati_od "original_value_col1",
    sati_do "original value",
    sati_do-sati_od "Difference"
    from accbtp_pliskljucenjaodobrenja
    where idplisklj= 22999;
    where this results in:
    hh:mi format orginal_value_col2 original_value_col1       original value            Difference             
    ------------ ------------------ ------------------------- ------------------------- ---------------------- 
    09:00        15:00              01.12.10                  01.12.10                  0,25                   
    09:00        15:00              01.12.10                  01.12.10                  0,25                   
    09:00        15:00              01.12.10                  01.12.10                  0,25                   
    09:00        15:00              01.12.10                  01.12.10                  0,25                   
    THX in advance, Adnan
    select trunc( mod( (e-j)*24, 24 ) ) ||':'||trunc( mod( (e-j)*24*60, 60 ) )  "Hr:Mi"
         from (
        select t.*,
               trunc(sysdate,'y')+jd+jh/24+jm/24/60 j,
               trunc(sysdate,'y')+ed+eh/24+em/24/60 e
          from t
              ) t
     
    

    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:96012348060

  • Problem with comparing two dates

    I'm a bit confused by the present. This is the query

    SELECT THE CHECK BOX
    WHEN TRUNC (mm.revised_validation_due_date) >
    TRUNC (mm.next_validation_date)
    THEN
    "superior".
    ON THE OTHER
    'no '.
    END
    compare,
    mm.revised_validation_due_date - mm.next_validation_date datediff,
    mm.revised_validation_due_date,
    mm.next_validation_date,
    To_char (mm.revised_validation_due_date, ' DD/MM/YYYY HH')
    revised_with_time,
    To_char (mm.next_validation_date, ' DD/MM/YYYY HH') next_with_time
    OF tbl_master mm
    WHERE mm.tbl_id = 802

    the output

    compare = greater
    DateDiff = 730487
    revised_validation_due_date = 2009-02-28
    next_validation_date = 2009-02-28
    revised_with_time = 2009-02-28 12:02
    next_with_time = 2009-02-28 12:02

    So... Why did the stated case out with a larger?

    This could be the problem:

    TO_CHAR (mm.next_validation_date, 'MM/DD/YYYY HH:MM:SS') next_with_time
    

    not looking at the set time, specifically the minutes
    the format mask must be

    TO_CHAR (mm.next_validation_date, 'MM/DD/YYYY HH:MI:SS') next_with_time
    

    not MM for a few minutes, but MI minutes

Maybe you are looking for

  • IPad Pro - definition

    I need help on the Ipad PRO "SETTING" lock only, my goal is to prevent users to edit, add, and change. Best password of difference just for the COMPUTER administrator to edit, add, and change. The only application of permits is the camera, the cloud

  • Failure of graphics rendering on Satellite Pro U400

    My webcam has worked very well for about three weeks, but now, at the opening of the Camera Assistant Software, it says "chart make it fail."I tried to update the driver for the webcam and the display driver, but it does not work. I googled this prob

  • Rate lowered when I went to W7...

    I play World of Warcraft and a few other games. My pace increased from 40 to 60 FPS on the game (WoW) to 8-15. It runs more slowly now. I came on Vista 64 bit and moved to W7-64 bit. Also I had always open then net and 2 other programs when I played

  • where can I find out what files are waiting to be burned to a disc? I have an old version of XP

    When I inserted a disc to burn files on, he gave me the message that there are queues to be burned to the disc.  How/where can I find out what files are waiting to be burned?

  • Accidentally deleted Security Center

    I accidentally deleted Security Center to the wide range of services on my computer?