How to Calculate Duration from Date Columns

Hello,
I would like to calculate duration from date columns. Using the following query
SELECT DISTINCT
EVENT_ID,
To_Char(RU.START_TIME, 'HH24:MI') START_TIME,
To_Char(RU.END_TIME, 'HH24:MI') END_TIME
FROM ROOM_USAGE RU
What I need is to subtract START_TIME from END_TIME and result should be in minutes.
Many Thanks,

But, i think you need to calculate the number of days if the days are not same -
satyaki>
satyaki>
satyaki>
satyaki>with ru
2 as
3 (
4 select '05-JAN-2007 15:10:20' start_time, '07-JAN-2007 19:20:20' end_time from dual
5 union all
6 select '08-JAN-2007 05:10:20' start_time, '07-JAN-2007 07:07:20' end_time from dual
7 )
8 select ru.start_time, ru.end_time, SUBSTR(numtodsinterval(to_date(RU.END_TIME,'DD-MON-YYYY HH24:MI:SS')-to_date(RU.START_TIME,'DD-MON-YYYY HH24:MI:SS'), 'DAY'), 12, 8) duration
9 from ru;
START_TIME END_TIME DURATION
05-JAN-2007 15:10:20 07-JAN-2007 19:20:20 04:09:59
08-JAN-2007 05:10:20 07-JAN-2007 07:07:20 22:03:00
satyaki>
Or, Am i missing anything?
Regards.
Satyaki De.
is it possible to to add the duration? making the total hours to 26:12 (twentysix hours and twelve minutes)

Similar Messages

  • How to calculate value from perticular column and row in pivot table

    Hi all,
    I am having following pivot table.
    Country
    A
    B
    C
    D
    F
    G
    H
    J
    K
    L
    M
    Grand Total
    Canada
    1
    1
    3
    3
    12
    14
    13
    97
    China
    8
    4
    3
    19
    India
    2
    47
    448
    176
    395
    3656
    1964
    1360
    8077
    USA
    1545
    352
    380
    26
    10
    4
    8
    32
    2054
    1023
    758
    4624
    UK
    12
    19
    13
    23
    33
    298
    Grand Total
    1545
    352
    381
    29
    72
    474
    184
    427
    5743
    3028
    2167
    13114
    Now I want sum of Columns A, B, C, K, M where Country = India in one field.
    and sum of D, F, g in another field. and sum of remainig columns in another field.
    How can i get sum of values with some where condition in pivot table.
    Thanks,

    Hi Michael,
    Following is the representation which i want
    CouRntry
    ROW LABLES
    A
    B
    C
    Total of
    ABC
    F
    G
    Total
    Of FG
    J
    K
    L
    TOTAL
    of JL
    Grand
    Total
    Canada
    1
    1
    3
    3
    12
    14
    13
    97
    China
    8
    4
    3
    19
    India
    2
    47
    448
    176
    395
    3656
    1964
    1360
    8077
    USA
    1545
    352
    380
    26
    10
    4
    8
    32
    2054
    1023
    758
    4624
    UK
    12
    19
    13
    23
    33
    298
    Grand Total
    1545
    352
    381
    29
    72
    474
    184
    427
    5743
    3028
    2167
    1
    Also if i get sum how can i add a column in between of the fields.
    Thanks

  • In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    In Pages 5.2.2: How do you go from 1 column to 2 and keep them on the same page?

    Sorry, I tried to say your answer solved my question, but I guess I told it that my response to you solved it. Now that I liked it, the solved option doesn't appear.

  • How to calculate any two date with diffence calculation by using obiee11g?

    Hi,
    i have a requirement like,
    location wise current month and previous month with movement calculation,can to tell me how to calculate any two date with diffence calculation
    by using obiee11g
    Note,
    I tried to implemented ago function as well as dynamic two dates calculation using $2-$1 methods..but i am getting the o/p it's self i am getiing some null value also that' why it's not tallying with our actual report.
    i tired to used ifnull(mesaurecolumn,0) also case condition on the mesaure colution still it's not tallying.
    THanks and Rds,
    Devarasu.R

    Hi,
    for Date Difference........
    TimestampDiff(interval, timestamp1, timestamp2)
    ex:TimestampDiff(SQL_TSI_DAY, cast('1-apr-2011' as date), current_date)
    Where:
    interval
    The specified interval. Valid values are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY,
    SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.
    Cheers,
    Aravind

  • How do I switch from one column to another in a simple 3-column document?  Seems lame, but I can't find the answer in "help"...

    How do I switch from one column to the next, skip around?  Tab key doesn't seem to do itl.  I can't find any "help" in "help".  Help.  Please.  Thank you.

    Hi Karen,
    It is simple.
    Columns fill with text as the text becomes enough to spill over from the previous column. Below is an example. I have used a huge (6" botom margin setting to shorten the page to a reasonable length for a screen shot, and turned on Show layout and Show invisibles so the column boundaries and invisible characters can be seen. Here there's no text in column 3 as there is only enough text to fill column 1 and part of column 2.
    As more text is added, it eventually fills column 2 and flows into column 3:
    You can force the text into the next column by inserting a column break. Here, a column break has repalced the paragraph break in column 2 (after 'fascilisi."):
    Regards,
    Barry

  • How to select 2column from 1 column values

    Hi All,
    How to select 2column from 1 column values
    Ex : In Emp they have JOB column
    JOB
    CLERK
    MANAGER
    SALESMAN
    MANAGER
    MANAGER
    ANALYST
    PRESIDENT
    SALESMAN
    CLERK
    CLERK
    ANALYST
    CLERK
    here i want to get output like as follows
    Ex: ejob1 ejob2
    ANALYST SALESMAN
    ANALYST SALESMAN
    Can anyone helps me in this,it is urget
    Thanks,

    Something like
    select a.job, b.job from scott.emp a, (select job from scott.emp) b
    CLERK     CLERK
    CLERK     SALESMAN
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     SALESMAN
    CLERK     MANAGER
    CLERK     MANAGER
    CLERK     ANALYST
    CLERK     PRESIDENT
    CLERK     SALESMAN
    CLERK     CLERK
    CLERK     CLERK
    CLERK     ANALYST
    CLERK     CLERK
    SALESMAN     CLERK
    SALESMAN     SALESMAN
    SALESMAN     SALESMAN
    SALESMAN     MANAGER
    ...

  • How to calculate AGE from two different date fields

    hi
    I need to calculate AGE from two different date fields.
    Can some help me how to do, when i try to do substraction formula it is showing error.
    Thank You
    Manu

    Manu wrote:
    Hi
    Both fields are in date format only, i need to calculate no . of days between two different dates
    Thanks
    ManuThe reason for the question about the format of the column is because the simplest solution only works on DATE columns. Others have mentioned this here, but if you want the difference between two date fields, you can use this formula:
    TIMESTAMPDIFF(SQL_TSI_DAY, date_column1, date_column2)
    The above being said, you still didn't tell me what you did, or what error message you received. So again, if the above formula didn't work, what did you do? Where did you put the formula? What was the exact syntax you used? What was the error message you got?
    Please don't make us work more than we need to. Answer all the questions in your next post. Thanks.

  • How can I extract a dates column from an ascii file

    I am extracting data from an ascii file and the rest of the data is extracted using read from spreadsheet, but the date appears as just the day e.g. 22 for 22nd, how can I get the date, format in ascii is e.g 22/04/2006, can I do this by specifying something at format of read from spreadsheet ? Cheers
    Emily

    Hi,
    I found the other day that there are instructions included inside the Read From Spreadsheet vi on how to modify it slightly to read strings rather than doubles.
    If you drop the Read From Spreadsheet  vi onto the block diagram and double click on it, you will open the front panel for the vi. If you then select the block diagram (for Read From Spreadsheet) you will see an 'instructions' frame below the main 'code', and the 3rd paragraph tells you how to modify the VI to read the spreadsheet as a set of strings rather then doubles. Save the vi as a new filename when you've edited it or you will overwrite the existing vi!
    Using the newly modified vi you can read in your entire spreadsheet, extract the dates as strings, then do any conversion necessary to the other columns of the sheet to change them into the types of value you require (eg doubles).
    I hope this helps.
    Mark
    Applications Engineer
    National Instruments

  • How do I select a date column and display the millesecond along with it.

    I am trying to select a date column from database and want to
    display millesecond with it. How do I do this. I am aware of
    the "alter session set NLS_DATE_FORMAT = 'MM/DD/YY HH:MI:SS'"
    command. However, I do not know how to display this with the
    millesecond.
    Thanks for all the help.

    Example:
    SQL> CREATE OR REPLACE JAVA SOURCE
      2  NAMED "MyTimestamp"
      3  AS
      4  import java.lang.String;
      5  import java.sql.Timestamp;
      6 
      7  public class MyTimestamp
      8  {
      9  public static String getTimestamp()
    10   {
    11   return (new
    12   Timestamp(System.currentTimeMillis())).toString();
    13   }
    14   };
    15  /
    Java created.
    SQL> CREATE OR REPLACE FUNCTION my_timestamp
      2    RETURN VARCHAR2
      3  AS LANGUAGE JAVA
      4  NAME 'MyTimestamp.getTimestamp() return java.lang.String';
      5  /
    Function created.
    SQL> CREATE TABLE test_time
      2    (date_col VARCHAR2 (23))
      3  /
    Table created.
    SQL> INSERT INTO test_time (date_col)
      2  SELECT my_timestamp
      3  FROM   dual
      4  /
    1 row created.
    SQL> SELECT date_col
      2  FROM   test_time
      3  /
    DATE_COL
    2001-11-02 14:58:51.766

  • Creating Time Dimension from date columns in fact tables.

    I remember watching a demo from a BI Tool a couple years ago, wich I swear was OBIEE, and the presentator stated it was possible to create a Time Dimension in the admin tool, based on a date column in other table.
    Can you guys tell me if there's such functionality in OBIEE?
    If so, how could I achieve that?!
    Thanks in advance!
    Marcos

    hi,
    You are trying to make Fact table as Dim table ???
    Fact table has some dim columns??
    We can do this by making a fact table as dim table ,create a dim hierarchy on that table
    Year level :Extract(year from fact_date_column)
    Month and year  level:CAST (Extract(month from fact_date_column) As CHAR(5) ) || CAST (Extract(yearfrom fact_date_column) As CHAR(5) )
    Like this
    But,be careful while doing this make sure that all joins and content levels are good
    As per my knowledge this is not a good way,Experts can add some words lets see!!!!!! :-)
    thanks,
    saichand.v

  • How to calculate the 'real data of arrival' in PO item

    Hi,
    Confirmation control keys with control type u201CDAu201D are MRP relevant
    1.     = New field time of transportation in calendar days
    2.     = Confirmation control type u201CABu201D (order confirmation)
    3.     = Confirmation control type u201CLAu201D (shipping notification)
    4.     = Confirmation control type u201CDAu201D (Date of arrival)
    When data 1-3 has been changed = 4 will be calculated again.
    Program requirements to calculate the u201Creal data of arrivalu201D:
    1.     When 1 >0 days then create 4 directly after placement of 2 (2 can be placed manually or automatically)
    2.     4 must be calculated: AB delivery date 2 + calendar date amount 1 = arrival date 4 (MRP gets a confirmed delivery      date by vendor plus transportation time)
    3.     When changes in 1 then change 4 (add calendar days to arrival date DA)
    4.      When changes in 2 then change 4 = u201Cnewu201D delivery date 2 plus calendar days 1 = new arrival date 4
    5.     When 3 u201CLAu201D is entered (manually/automatically) then calculate: shipping date LA 3 plus calendar days 1 = new arrival date in 4
    6.     When 1 has been changed then calculate 4 new (Check is 2 existing then use 2, check is 2 + 3 existing then use 3)
    7.     When 2 or 3 has been changed quantity then also update quantity in 4
    8.     When 2 has been canceled then cancel 4, too
    9.     When 3 has an inbound delivery document no. in place then copy the same no. in the inbound delivery field 4 and in the new column in MRP (MD04, see MRP view below)
    i have a lot of confuseging in this lines of code,even where u write i don't know in BADI . we are implement in BADI only.
    if possiable give me code for this requriment. . this line of code in which method we write,please guide me.............

    SDN is not your code factory, please research yourself before posting, maybe ask whoever handed you this requirement?
    Thread locked.
    Thomas

  • Doubt  in  how to   calculate  net  due date

    Hi..
    Experts   i have   doubt  in my  salesmen  ageing  report  i have to  display
    netamout    day  wise  in the range of   0-30 days , 30-60  days and  > 60 days
    how to calculate  the date difference between  to  date  one is invoice creation  date  and another  one is  system date.
    Give  me  any   function  module  available  to count  the  date  difference
    and how  i filter  the  amount  date  wise.
    Thanks Regds
    Prabir Kumar Dandpat

    Hi,
    check fm;
    SD_DATETIME_DIFFERENCE
    regards,
    Navneeth K.
    Message was edited by:
            Navneeth Bothra

  • From  date column I want to pick the hours only......

    Dear All
    I am facing the following problem.
    I having following date format in database of date column
    4/7/2006 10:26 AM
    4/7/2006 07:18 PM
    from this date column I want to pick the hours only , For ex. 10, 07 resp.from the above record.
    I tried it to solve using SUBSTR and LTRIM-TRIM function, but this functions will truncate the time format and so unable to pick the Hours.
    Is there any other solution for this.
    Also the date column I have is in 12 Hours(AM/PM) format I want to convert it into 24 Hours . Like 07 PM . I want it to 19.
    Thanks
    Vishal.

    TEST@db102 SQL> select * from test;
    C1
    4/7/2006 10:26 AM
    4/7/2006 07:18 PM
    TEST@db102 SQL> select to_char(to_date(c1,'dd/mm/yyyy hh:mi PM'),'hh24') from test;
    TO
    10
    19
    TEST@db102 SQL>                                               

  • How to add attributes in Data Column for automatic changes

    Hello everybody,
    Could you give me an advice?
    I have characteristic and attribute assigned to it.
    I want to make what when i change  characteristic(variable) its attribute in planning layout changes too. So in planning area window in <b>Characteristics Rels</b> tab i made "<i>Derivation, Combination Check and Proposal</i>" with main characteristic and its atribute. Everything works fine, but problem is, that attribute can be only in <b>Header</b> or in <b>Lead column</b>. 
    In planning layout i want to add what attribute in data column.
    Maybe where is other solutions?
    Thanks in advance
    Best Regards,
    Arunas

    Hy, Srini,
    Thanks for your response.
    There is a simple example, which describes the main principle of my solution:
    Characteristic DIVISION
    A
    B
    (filled with master data)
    Characteristic LEVEL
    1
    2
    (filled with master data)
    Characteristic NAME
    Ben
    John
    (filled with master data)
    char. LEVEL, NAME are attributes for char. DIVISION
    DIVISION with master data:
    Division  Level  Name
       A        1     Ben
       B        2     Jhon
    Planning Layout:
    In header section is char. DIVISION (variable)
    When I select DIVISION with value A, in layout values for attributes should be displayed automaticaly:
    DIVISION = A
    NAME
    LEVEL
    (Lead column)
    (Data column)
    Ben
    1
    I find solution to do it with Characteristic Rels, but i can't insert char. LEVEL into Data Column, it can be just
    in Lead Column.
    I don't know how to do it.  
    Could you suggest something?
    Best Regards,
    Arunas

  • How to get valid from date in KONH Table

    Hi ,
          I am sending COND_A idoc for MRP. Now when I create a record using VK11,the valid from date is fine.
    But while changing the same using VK12 changed date does not reflect in KONH Table (when the new valid from date is greater the the previous one) .I understand the SAP Logic behind this from previous threads .
    But my issue is this :
    Suppose I have a Material X created with Valid from = 10.01.2011 & valid to = 31.12.9999
    Now I change this Valid from = 28.01.2011 & valid to = 31.01.2011.
    Now how can I send the data for 28.01.2011 in my I-doc , as KONH still has 10.01.2011 as valid from date.

    even if you send the data for 28.01.2011, it should pick up the condition record because the start date for condition record is in past? why do you think it is a problem? now if your concern is that if your input date is 27.01.2011 and it should not pick this condition (that is a different matter altogether)...

Maybe you are looking for

  • Can't get LR CC to run

    I see I'm not alone, restarted computer, uninstalled it twice, reinstalled and still wouldn't run.. At lease light room 5.7.1 is still working..

  • Export to Excel in Web Analyzer: Change description

    In Web Analyzer we have a button Export to Excel. When we click that button the report gets downloaded in to excel. By default the excel sheet will be saved as example 0Analysis_Pattern-87. Is there any way, by default when i click on export to excel

  • Print Design Document No. on P.O.

    Dear all, Please suggest me how can i get print of Design Document No. & thier Version no. on P.O. {The design document No. is in MM01 -> Basic Data 2 } "Note : Is it possible by tick remove of Design document assine in same field. If yes please sugg

  • No photos on ipad but still uses 1.6GB

    I've deleted every photo and video on my iPad, still the usage stats tell me it's using 1.6 GB for photos & camera !! I've got an iPad 3, iOS 8.2, 64GB WiFi. What's wrong????

  • Search error, think its my sql

    Hello, I followed the How To: Extend the Easy Report doc and everything is fine until I reach the point of selecting the column under ADD/MODIFY CONDITIONS. I select the drop down list and my only choice is "No Column", which seems fine to me since I