How to get the diff between two dates  -  # of days

Hi Experts,
I have requirement to know the difference between dates. In my presentation layer two columns as created date and updated date. I want to know the difference in # of days in the presentation services.
Please provide some pointers.
Thanks in adv
svr

Hi,
In the presentation layer you can create a column with a custom formula of this:
TIMESTAMPDIFF(SQL_TSI_DAY, datecolumn1,datecolumn2)
The result shown in the column will be the difference in days between the two dates.
Regards,
Matt

Similar Messages

  • 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 to get the difference between two date

    Hello,
    I want to know how to write a code the tell me the difference between two date, I am using
    oracle.jbo.domain.Date
    i have a rent date and return date so my code is
    Date rent=(Date)nr.getAttrbute("RentDate"),ret=(Date)nr.getAttrbute("ReturnDate");
    is there a way to know the difference in days between those two dates ?
    Thanks

    hi,
    try this.....
    DateFormat formatter = new SimpleDateFormat("E MMM dd HH:mm:ss Z yyyy");
    Date date = (Date)formatter.parse(dateStr); //// dateStr <- from date value (that is string value)
    Date dateto = (Date)formatter.parse(datetostr); //// datetostr <- to date value (to date getting from as a string)
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    Calendar calto = Calendar.getInstance();
    calto.setTime(dateto);
    fromDate = cal.get(Calendar.DATE) + "/" + (cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.YEAR);
    toDate = calto.get(Calendar.DATE) + "/" + (calto.get(Calendar.MONTH) + 1) + "/" + calto.get(Calendar.YEAR);
    // System.out.println("from Date : " + fromDate);
    if ((fromDate != null && toDate != null) && (date.compareTo(dateto) > -1) ) {                  
    fc.addMessage("VacationQueryComponent", new FacesMessage(FacesMessage.SEVERITY_ERROR, "From Date cannot be lower than To Date", "From Date cannot be lower than To Date"));
    fc.renderResponse();
    thks.

  • How to get the difference between two dates???

    HI I have two dates and I want to test if there is an hour between them.
    Is there a way to compare two dates like mySQL can with dateDiff(date1,date2);
    Thanks alot.
    Graham

    This link is now out of date as they have revamped the structure. Yep. Here it is again: http://forum.java.sun.com/thread.jsp?forum=31&thread=502686
    I've also noticed that my comment regarding daylight saving was misleading. The demonstrated method for calculating difference between Dates is reliable. However, one needs to be careful when interpreting Dates in a daylight saving timezone.

  • How to get the difference of two dates in years,months and days

    Hi friends,
    how to get the difference of two dates in years,months and days
    for ex 2 years 3 months 13 days
    select (sysdate-date_Start) from per_periods_of_service
    thanks

    Something like this...
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('17-nov-2006','dd-mon-yyyy') as c_start_date, to_date('21-jan-2008','dd-mon-yyyy') as c_end_date from dual union all
      2             select to_date('21-nov-2006','dd-mon-yyyy'), to_date('17-feb-2008','dd-mon-yyyy') from dual union all
      3             select to_date('21-jun-2006','dd-mon-yyyy'), to_date('17-jul-2008','dd-mon-yyyy') from dual
      4             )
      5  -- end of test data
      6  select c_start_date, c_end_date
      7        ,trunc(months_between(c_end_date, c_start_date) / 12) as yrs
      8        ,trunc(mod(months_between(c_end_date, c_start_date), 12)) as mnths
      9        ,trunc(c_end_date - add_months(c_start_date, trunc(months_between(c_end_date, c_start_date)))) as dys
    10* from t
    SQL> /
    C_START_D C_END_DAT        YRS      MNTHS        DYS
    17-NOV-06 21-JAN-08          1          2          4
    21-NOV-06 17-FEB-08          1          2         27
    21-JUN-06 17-JUL-08          2          0         26
    SQL>But, don't forget that different months have different numbers of days, and leap years can effect it too.

  • How to get time diff between to date

    Hi all,
    How can I get the time diff. between two date in a single query
    as in the example below-
    select
    to_char(sysdate,'dd-mm-yyyy hh:mi:ss') d1,
    to_char(sysdate-45,'dd-mm-yyyy hh:mi:ss') d2,
    months_between(sysdate,(sysdate-45)) mon_diff
    /* how can I get the time diff in terms of hour ,min, seconds*/
    from dual

    314214, The difference between any two Oracle dates is measured in Days and fractions thereof.
    A day = 24 hrs, = 1440 minutes, = 86400 seconds
    Use the mod function on the difference
    HTH -- Mark D Powell --

  • How to get the difference between two HashMaps

    i have two HashMaps
    HashMap first = new HashMap<Integer,Object>();
    HashMap second = new HashMap<Integer,Object>();
    How to get the difference between one and two and put the result in the third
    HashMap third = new HashMap<Integer,Object>();

    My bad, difference of course means removeAll():Map<Integer,Object> first = new HashMap<Integer,Object>();
    Map<Integer,Object> second = new HashMap<Integer,Object>();
    Map<Integer,Object> third = new HashMap<Integer, Object>(first);
    third.keySet().removeAll(second.keySet());No loops needed.

  • How to get the difference between two columns in a column group

    Hi All,
    My first time here and really new to programming. I would like to get the difference between 2 columns that are inside 
    a column group.
    Here is my sample table below: The Column Group is PeriodNumber and can only choose 2. like 1 and 2.. I would like to have a third row which will simply calculate the difference between the amounts in PeriodNumber 1 and 2.
                                PeriodNumber          
    Account                    1                            2     
    1) Cash                10,000                15,000
    2) Receivables      12,000                11,500
    3) Equipment          5,000                  5,500
    Total Assets          27,000                32,000

    Hi yabgestopa,
    From your description, you want to get the difference between two columns in a column group. After testing it in my environment, we can use custom code to achieve your requirement. For more details, you can refer to the following steps:
    Copy the custom code below and paste it to your report. (Right-click report>Report Properties>Code)
    Dim Shared Num1 As Integer
    Dim shared Num2 As Integer
    Public Function GetAmount(Amount as Integer, Type as String)
    If Type = "1" Then
    Num1=Amount
    Else
    Num2=Amount
    End If
    Return Amount
    End Function
    Public Function GetDif()
    Return Num1-Num2
    End function
    Right-click the second column to insert a third column with Outside Group-Right.
    Then use the expressions below in the matrix.
    =Code.GetAmount(Fields!Amount.Value,Fields!PeriodNumber.Value)
    =code.GetAmount(Sum(Fields!Amount.Value),Fields!PeriodNumber.Value)
    =Code.GetDif()
    The report looks like below.
    If you have any questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to get the difference of two dates?

    let's say i have a table named tblData and has 4 columns: data_RefNo, data_DateReported, data_TargetDate, data_Data
    tblData returns 2 rows.
    data_RefNo.............data_DateReported.............data_TargetDate........................data_Data
    10000................10-20-2004 10:55:44 AM........10-20-2004 10:57:44 AM........Slow Response Time
    10000................10-21-2004 10:55:44 AM........10-21-2004 11:55:44 AM........Bug Error
    i just wana ask how to get the difference of the date_DateReported and date_TargetDate.
    i tried this code but it didnot work
    public Vector get_con_pf()
      Vector vData = new Vector();
      String query  = "SELECT * FROM tblData WHERE data_RefNo= '"'10000'"'";
      try
        DBConnect db = new DBConnect();
        db.openCon();
        ResultSet rs = db.execute(query);
        while (rs.next())
          vData.addElement(DATEDIFF(mi, rs.getString("st_DateReported"), rs.getString("st_TargetFinishDate")));
        db.closeCon();     
      catch (Exception e)
        System.out.println("Error: " + e );
      return vData;   
    i want to return the difference of the data_DateReported and date_TargetDate, i did this
    vData.addElement(DATEDIFF(mi, rs.getString("st_DateReported"), rs.getString("st_TargetFinishDate")));but it didnot work.
    How do i get that? because i want to return a vector.
    the code must return the values:
    2 for the 1st rows because the difference is only 2 minutes, and
    60 for the 2nd row.

    ooops i tried this one:
    query = "SELECT *, DATEDIFF(mi, data_DateReported, data_TargetDate) AS diff FROM tblData WHERE data_RefNo = '10000'";and it works.
    hehehehe!!!!!!
    problem solved! :)

  • How to find the difference between two date?

    Hi,
    I currently writing a date comparision program. Below is the idea analogy,
    Currently i need to find how many day differences between 30 July 2003 and 22 June 2004. How can i use java to code it?
    Thanks.

    there doesn't seem to be a direct way but try this:int daysBetween = 0;
    Calendar c = new GregorianCalendar(2004, Calendar.JULY, 30);
    Calendar d = new GregorianCalendar(2003, Calendar.JUNE, 22);
    while (c.get(Calendar.YEAR) != d.get(Calendar.YEAR)) {
        daysBetween += 360;
        d.add(Calendar.DAY_OF_YEAR, 360);
    daysBetween += c.get(Calendar.DAY_OF_YEAR) - d.get(Calendar.DAY_OF_YEAR);This gives the correct result of 404 (= 8 days from June 22 to June 30 + 366 days between July 1 of 2003 and 2004 + 30 days from July 1 to July 30)

  • How to get the 'link' between two tables

    hi pple
    i need to find out HOW two tables are related.
    sample tables:
    SHIPS ( HULL_ID [PK] , VESSEL_NAME, GROSS_TONNAGE )
    EQUIPMENT ( E_ID [PK] , HULL_ID [FK frm SHIPS], DESC )
    PARTS ( PART_ID [PK] , E_ID [PK, FK frm EQUIPMENT], MANUFACTURER_ID)
    --> SHIPS and PARTS are some how related thro' EQUIPMENT.
    i need to get this relationship:
    Ships --> Equipment (E_ID) --> PARTS
    currently, i can get the direct parent and child tables of a given table using:
    SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Child_Tables
    FROM ALL_CONSTRAINTS
    START WITH R_CONSTRAINT_NAME in
    select constraint_name
    from all_constraints
    where table_name = '%table_name%'
    and constraint_type = 'P'
    CONNECT BY PRIOR CONSTRAINT_NAME = R_CONSTRAINT_NAME ;
    To get ALL parents:
    SELECT lpad ( ' ', 2 * ( LEVEL - 1 ) ) || table_name as Parent_Tables
    FROM ALL_CONSTRAINTS
    where owner = 'CHARTUSER'
    START WITH CONSTRAINT_NAME in
    select constraint_name
    from all_constraints
    where table_name = '%table_name%'
    and constraint_type = 'R'
    CONNECT BY PRIOR R_CONSTRAINT_NAME = CONSTRAINT_NAME ;
    what i need to do is:
    1) get children & parents of SHIPS
    2) for each element of (1), get children, parents till i get PARTS
    3) so, i will get EQUIPMENT and then, PARTS.
    this wud be very expensive. my appln is in Java and i will need to call these functions - that makes it more complex. is there any simpler way out?
    and my main problem is to find out WHAT attributes line two tables. this wudnt be a big deal if it were just simple parent-child tables. but, how do i find out the attributes that link PARTS and SHIPS table?
    any ideas? -please help.
    thanks in advance
    --$uDhA

    Dear Srikanth,
    This tables can be used once we come to know whether its a customer or vendor line item but in our case we using the GL account as reference have to knock off the entries.How we come to know that aginst the GL whether its a customer or vendor line item.. Then it should route to this table.
    Suggest me if any options are there.
    Regards,
    Balaji.c

  • How  to get  time diff between two rows ???

    I need to calculate the time difference of rows based on a column's value how do i do that ??
    say i have a table statistics
    id timing
    100 10-JAN-07 09.52.10.000000 AM
    200 10-JAN-07 09.59.10.000000 AM
    300 10-JAN-07 09.59.30.000000 AM
    I want to get the time taken by 200 ie timing of 200 - timing of 100
    how do i get that .
    similarly for id 300 and so on .
    regards
    Shub

    SQL> create table mytable
      2  as
      3  select 100 id, to_timestamp('10-JAN-07 09.52.10.000000 AM','DD-MON-RR HH:MI:SS:FF AM') timing from dual union all
      4  select 200 , to_timestamp('10-JAN-07 09.59.10.000000 AM','DD-MON-RR HH:MI:SS:FF AM') from dual union all
      5  select 300 , to_timestamp('10-JAN-07 09.59.30.000000 AM','DD-MON-RR HH:MI:SS:FF AM') from dual
      6  /
    Tabel is aangemaakt.
    SQL> select id
      2       , timing
      3       , timing - lag(timing) over (order by timing) diff
      4    from mytable
      5  /
       ID TIMING                         DIFF
      100 10-01-07 09:52:10,000000000
      200 10-01-07 09:59:10,000000000    +000000000 00:07:00.000000000
      300 10-01-07 09:59:30,000000000    +000000000 00:00:20.000000000
    3 rijen zijn geselecteerd.Regards,
    Rob.

  • How to calculate the difference between two dates?

    Hello,
    I would like to write some code which figures out how many days are between the Date_of_change (which is of datatype DATE, length 7 and of format DD-MON-YY) and the current date today. Then if the difference between Date_of_change and the current date is greater that 30 days for example then I would like to delete that record from the database.
    Thanks
    Doug

    Something like this should work:
    SQL> select * from emp order by hiredate ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7934 MILLER     CLERK           7782 21-OCT-2005       1300                    10
          7902 FORD       ANALYST         7566 22-OCT-2005       3000                    20
          7900 JAMES      CLERK           7698 23-OCT-2005        950                    30
          7876 ADAMS      CLERK           7788 24-OCT-2005       1100                    20
          7844 TURNER     SALESMAN        7698 25-OCT-2005       1500          0         30
          7839 KING       PRESIDENT            26-OCT-2005       5000                    10
          7788 SCOTT      ANALYST         7566 27-OCT-2005       3000                    20
          7782 CLARK      MANAGER         7839 28-OCT-2005       2450                    10
          7698 BLAKE      MANAGER         7839 29-OCT-2005       2850                    30
          7654 MARTIN     SALESMAN        7698 30-OCT-2005       1250       1400         30
          7566 JONES      MANAGER         7839 31-OCT-2005       2975                    20
          7521 WARD       SALESMAN        7698 01-NOV-2005       1250        500         30
          7499 ALLEN      SALESMAN        7698 02-NOV-2005       1600        300         30
          7369 SMITH      CLERK           7902 03-NOV-2005        800                    20
    14 rows selected.
    SQL> delete from emp where hiredate < sysdate - 30 ;
    10 rows deleted.
    SQL> select * from emp order by hiredate ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 31-OCT-2005       2975                    20
          7521 WARD       SALESMAN        7698 01-NOV-2005       1250        500         30
          7499 ALLEN      SALESMAN        7698 02-NOV-2005       1600        300         30
          7369 SMITH      CLERK           7902 03-NOV-2005        800                    20
    4 rows selected.
    SQL>

  • How to get the difference between two BufferedImages?

    All the BufferedImage which is grabbed from AWT may be same each other,
    i only want to get the different part of two continuous BufferedImages and send ti over internet.
    I have compared two BufferedImages by RGB (int[]), but this process wastes 400~500ms,it's terrible,:)
    who has any good idea about this?
    thanks
    Best Wishes
    mauvespan

    thanks ! cary ,
    I have a list contained some BufferedImages gotten from AWT component,and then these images
    will be transfered to client and displayed in Internet explore ,actually there are only some difference
    between two continuous BufferedImages,i don't want to transfer the WHOLE image to client,SO i
    want to handler every image before sending to client , at last, the different part will only be sent to client.
    All these ideas will be contained this method:
    * Compare the specified two BufferedImages and return the different part between them.
    * @param ref the specified first image
    * @param gen the specified sencond image
    * @return the different part between the specified two images.
    public static void BufferedImage compareBufferedImage(BufferedImage ref,BufferedImage gen){
    to finish this method ,do you have any good ideas?or sample code?
    thanks
    Best wishes
    mauvespan

  • How to get the distance between two object!!!

    I have two GEOM object and want to know the distance between them, may u give me some solution to find the distance between them.

    Hi!,
    SDO_GEOM.SDO_DISTANCE
    see: http://www.oracle.com/technology/documentation/spatial.html
    regards, Andreas

Maybe you are looking for

  • Thumbnail Icons on Desktop

    I have PSA SE V3 on my computer and recently saved some JPEG files received via email to my desktop. The icons for the files where thumbnails of the actual image in the file, not a generic JPEG icon. When I updated all Adobe applications the other da

  • How to display a block next to another bock in a selection screen?

    Hi, I want to show several blocks in a selection screen, but they are displayed one below the other. How can I display them parallel? My Coding: SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001 NO INTERVALS. *parameters SELECTION-SCREEN E

  • Verizon Disconnected My Dry Loop DSL

    I have had the Dry Loop DSL for two years after dropping my landline.  I got the letter from them in May saying they were no longer offering the Dry Loop but for those that have it, nothing changes as long as you don't make a change to your account.

  • Sybase connection causing error

    Hi, I am trying to connect to a sybase database using JDBC. Do I need to issue an 'use database_name' command to the sybase database before I can start selecting from the tables in the database? I have tried doing the following but it is giving me an

  • MacBook Pro hangs in gray screen after security update

    I just allowed software update to download and install the latest Safari update and Security update 2009-6. During the restart my macbook just hung on the gray screen with the spinning gear. I've tried starting in target disc mode but the iMac doesn'