Difference between date datatype

hi all,
We have oracle 10G R2 on windows.
we have table called set_1 as
SQL> desc set_1;
Name                                      Null?    Type
SL_NO                                              NUMBER
STARTTIME                                          DATE
ENDTIME                                            DATEin the table we have data like
SQL> ed
Wrote file afiedt.buf
  1  select sl_no,to_char(starttime,'dd-mm-yyyy hh24:mi:ss')starttime,
  2  to_char(endtime,'dd-mm-yyyy hh24:mi:ss')endtime
  3* from set_1 where rownum<=5
SQL> /
     SL_NO STARTTIME           ENDTIME
         4 11-12-2012 13:15:00 11-12-2012 13:15:36
        12 11-12-2012 15:15:00 11-12-2012 15:15:01
        20 11-12-2012 17:15:00 11-12-2012 17:15:12
        29 11-12-2012 19:30:00 11-12-2012 19:30:01
        41 11-12-2012 22:30:00 11-12-2012 22:30:01I want to retrive the data which will have fourth column difference between starttime and endtime in minuts and seconds only.
for that i wrote query but showing error...
select TO_CHAR(STARTTIME,'DD-MM-YYYY HH24:MI:SS') STARTTIME,TO_CHAR(ENDTIME,'DD-MM-YYYY HH24:MI:SS') ENDTTIME,
TO_CHAR(STARTTIME,'MM:SS')-TO_CHAR(ENDTIME,'MM:SS') DIFFERENCE FROM SET_1;
Error
TO_CHAR(STARTTIME,'MM:SS')-TO_CHAR(ENDTIME,'MM:SS') DIFFERENCE FROM SET_1
ERROR at line 2:
ORA-01722: invalid numberCan anybody help me to achive this...

>
I want to retrive the data which will have fourth column difference between starttime and endtime in minuts and seconds only.
>
Always start with something simple.
You can use the NUMTODSINTERVAL function to convert a number (e.g. the difference in seconds between two date values) to days, hours, minutes and seconds.
See the SQL Language doc
http://docs.oracle.com/cd/E11882_01/server.112/e17118/functions117.htm
WITH DATA AS (
  SELECT TO_DATE('11-12-2012 13:15:00','dd-mm-yyyy hh24:mi:ss')STARTTIME,
  TO_DATE('11-12-2012 13:15:36','dd-mm-yyyy hh24:mi:ss') ENDTIME
  FROM DUAL
  UNION ALL
  SELECT TO_DATE('11-12-2012 13:15:00','dd-mm-yyyy hh24:mi:ss')STARTTIME,
  TO_DATE('29-12-2012 09:29:31','dd-mm-yyyy hh24:mi:ss') ENDTIME
  FROM DUAL
SELECT DATA.*, numtodsinterval((endtime - starttime) * 86400, 'SECOND') myDIFF
from data;
STARTTIME,ENDTIME,MYDIFF
12/11/2012 1:15:00 PM,12/11/2012 1:15:36 PM,+00 00:00:36.000000
12/11/2012 1:15:00 PM,12/29/2012 9:29:31 AM,+17 20:14:31.000000If that is not what you want then you will need to write a function to compute the exact form that you want.
Here is a Java sample that converts a time in milliseconds to HH:MI:SS.nnnn format. You would use a similar PL/SQL function.
*  elapsed time in hours/minutes/seconds/milliseconds
* @return String
public static String getHoursMinutesSecondsFromMilliTime(long milliTime) {
    int milliSecondsPerSecond = 1000;
    int milliSecondsPerMinute = 60 * milliSecondsPerSecond;
    int milliSecondsPerHour   = 60 * milliSecondsPerMinute;
    long hours;
    long minutes;
    long seconds;
    long milliSeconds;
    long modRemainder;
    String result;
    hours = milliTime / milliSecondsPerHour;
    modRemainder = milliTime - (hours * milliSecondsPerHour);
    minutes = modRemainder / milliSecondsPerMinute;
    modRemainder = modRemainder - (minutes * milliSecondsPerMinute);
    seconds = modRemainder / milliSecondsPerSecond;
    milliSeconds = modRemainder - (seconds * milliSecondsPerSecond);
    result = hours + ":" + minutes + ":" + seconds + ":" + milliSeconds;
    return result;
}

Similar Messages

  • What is difference between data base structure and stucure  in program

    what is difference between data base structure and stucure  declared in program  level . can  explain cleary if knows

    Hi,
    Data base structure is global decalaration you can reffer this structure in any of your developments, when ever you cahange this structure the changes automatically will get updated in all the programs.
    coming to structures in program it is local to your program only, if you want to change the structure again you have to open the program and do the necessary changes.
    Reward if useful.
    Thanks,
    Sreeram.

  • Difference between Data staging and Dimension Table ?

    Difference between Data staging  and Dimension Table ?

    Data Staging:
    Data extraction and transformation is done here.
    Meaning that, if we have source data in flat file, we extract it and load into staging tables, we take care of nulls, we change datetime format etc.. and after such cleansing/transformation at then end, load it to Dim/Fact tables
    Pros: Makes process simpler and easy and also we can keep track of data as we have data in staging
    Cons: Staging tables need space hence need memory space
    Dimension Table:
    tables which describes/stores the attribute about specific objects
    Below is star schema which has dimension storing information related to Product, Customer etc..
    -Vaibhav Chaudhari

  • Difference between date info object in characteristics and keyfigure

    What is the difference between "date" data type in characteristic and keyfigure?
    Thanks in advance.
    Raj

    Hi Rajasekhar,
    If date is characteristics,query can be analysed based on date and filters can also be set using this date.
    If it is key figure query cannot be analysed based on date,
    Based on requirements,we have to decide whether it should be chatracteristic or key figure
    Regards
    Prakash

  • Find difference between date

    I need to know how i can find difference between date
    like Joining date: 01-jan-2009 Today 10-jan-2010 result will be "1 year 10 days"
    I need it in Oracle forms 6i. plz help me...

    Hi,
    In oracle forms you can use
    RESULT :=
    TRUNC ((:date2 - :date1 + 1) / 365)
    || ' year and '
    || MOD (:date2 - :date1 + 1, 365)
    || ' days';
    in sql you can use
    SELECT TRUNC ((:date2 - :date1 + 1) / 365)
    || ' year and '
    || MOD (:date2 - :date1 + 1, 365)
    || ' days'
    FROM DUAL;

  • Counter KF with 1 & 0 and difference between data type NUMBER (DEC) and INTEGER (INT4)

    Hi,
    I need to create a counter kf which should populate 1 and 0 to this counter field. Please let me know is there any difference between data type
    NUMBER (DEC) and INTEGER (INT4).
    Please suggest.
    Thanks & Regards,
    Pavan kumar

    Hi Pavan,
    The basic difference between Number(DEC) and INT4 is its internal storage in system.
    For Number (DEC) - Value internally stored as packed number with 3 decimal places whereas INT 4 as 4 byte integer without decimal places.
    For counter KF, you can go for INT 4.
    Hope this helps.
    Thanks

  • Difference between data target & Infoprovider.

    Hi all,
    Difference between data target & Infoprovider.
    why cube is best in performance wise other than ods,multiproviders.
    Thanks,
    cheta.

    A data target is an object into which data is loaded. Data targets are the physical objects relevant during data modeling and when loading the data.
    Structure
    Data targets are:
    InfoCubes
    ODS objects
          InfoObjects (characteristics with attributes, texts or hierarchies).
    There are differences between:
    Pure data targets for which no queries can be created or executed. An InfoCube might only be used as a data source for another InfoCube. This is also possible for ODS objects and InfoObjects.
    If you want a characteristic to appear in the InfoProvider tree, you have to assign an InfoArea to it. You can define update rules for the characteristic in the InfoProvider tree, and use them to load attributes and texts.
    You can turn a characteristic into a data target only if the characteristic contains texts or attributes. It is not possible to use update rules to load hierarchies.
    Data targets for which queries can be defined. These are called InfoProviders.
    <Request for points removed>
    Regards
    Hemant
    Message was edited by:
    Moderator

  • Difference between Data Class and Delivery Class

    What is the Difference between Data Class and Delivery Class , what happens Phisically to the Data .
    Moderator message: what is the difference between your question and a question that we'd welcome here in the forums?
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Thomas Zloch on Nov 22, 2010 1:17 PM

    What is the Difference between Data Class and Delivery Class , what happens Phisically to the Data .
    Moderator message: what is the difference between your question and a question that we'd welcome here in the forums?
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    Edited by: Thomas Zloch on Nov 22, 2010 1:17 PM

  • Difference between Data Provider and extractor.

    Hi
    Can someone help me in understanding difference between data providers and data extractor.
    I have gone through some documents but not able to get the exact difference between them.
    What is the exact role of data provider and extractor with respect to sap solution manager.
    Is data provider== Data extractor?
    Thanks,
    Vijay

    Hello Vijaya,
    From my perspective the Data Providers are responsible for collecting metric values from the monitored objects on the managed sources systems and sending these to the Solution Manager Monitoring and Alerting Infrastrucure.
    Data extractors on the other hand are the reporting objects which are defined on the BW part of Solution Manager and can be enabled by configuring some monitoring scenario's. Once these data extractors are enabled, they will use the data from the "Data Providers" (see above) to setup nice BW reportings on the Solution Manager monitoring dashboards.
    I hope this answer helps you.

  • Difference between Dates: BW Query???

    Hello all,
    A.I have to get the difference between dates i.e Date1 and Date2.
    I have used a 2 formula variables for each one of them with Replacement path - Key - number as the settings.
    When i execute the difference between the 2 formula variables, i get inconsistent results if the dates are from 2 different months.
    Example(Correct Result)
    Date1 = 14.02.2005
    Date2 = 10.02.2005
    Result = 4
    Example(Incorrect Result)???????
    Date1 = 14.02.2005
    Date2 = 10.01.2005
    Result = 104
    Iam know that system is converting the date as a number like 20040214 and 22040110 and just substracts.....This is not correct....any solution to circmvent this problem???
    B.If iam using a user-exit for variables, how to pass the values Date1 and Date2 to user-exit so that i can calculate the difference of days using a function module.
    I know how to use a user-exit but not sure about working on 2 fields at a time for a formula variable????

    1) For the first problem, I think you should play with the replacement path settings (type, offset,...).  I did this before and I'm sure it worked.
    2) If the variables are entered in the variable screen there is no problem to use a function module (it works with steps --> look at the how-to), but I think you want to calculate not on variables but on the keyfigure values itself, in this case you will have to use virtual characteristics.  There is also a how-to about this, I can't help you with the details my self.
    kr,
    Tom

  • Difference Between data target and infoprovider

    Hi Experts,
    I am new to BW
    What is the difference between data target and  infoprovider
    Thanks and Regards,
    saveen

    Hi Saveen,
    InfoProvider is an object on which BEx queries are created. It provides information (data) to the queries when they are executed. InfoProviders may contain data (like cube) or may not contain data (like multiproivder and InfoSet).
    Data Target is an object to which you will load the data, like cube, ODS or InfoObject. But it is not necessary that each data target is an InfoProvider...like you may have ODS objects that are not enabled for reporting, but you are loading data to them for staging purpose.
    Hope this helps...

  • Whats  basic difference between data and types while declearing the itab

    whats  basic difference between data and types while declearing the internal tables...
    DATA : BEGIN OF t_vbap OCCURS 0,
    vbeln1 LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
    kwmeng LIKE vbap-kwmeng,
    netpr LIKE vbap-netpr,
    netwr LIKE vbap-netwr,
    werks LIKE vbap-werks,
    matnr LIKE vbap-matnr,
    arktx LIKE vbap-arktx,
       END OF t_vbap.
    vs
       TYPES : BEGIN OF t_vbap,
    vbeln1 LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
    kwmeng LIKE vbap-kwmeng,
    netpr LIKE vbap-netpr,
    netwr LIKE vbap-netwr,
    werks LIKE vbap-werks,
    matnr LIKE vbap-matnr,
    arktx LIKE vbap-arktx,
       END OF t_vbap.
    and vs
      TYPES : BEGIN OF t_vbap,
    vbeln1 LIKE vbeln,
    posnr LIKE posnr,
    kwmeng LIKE kwmeng,
    netpr LIKE netpr,
    netwr LIKE netwr,
    werks LIKE werks,
    matnr LIKE matnr,
    arktx LIKE arktx,
       END OF t_vbap.

    hi,
    like -> used for refering existing data elements in data dictionary or in sap
    type -> used for refering existing data types in sap.
    types: used for creating used defined structure of tables which has fields from more tahn one table.
    diff b/w types and type in creation of internal tables is that when u create a table with types then u can use same for work area creation also.
    ex:
    TYPES : BEGIN OF t_vbap,
    vbeln1 LIKE vbeln,
    posnr LIKE posnr,
    kwmeng LIKE kwmeng,
    netpr LIKE netpr,
    netwr LIKE netwr,
    werks LIKE werks,
    matnr LIKE matnr,
    arktx LIKE arktx,
    END OF t_vbap.
    data: itab1 type t_vbap
            wa_itab1 type t_vbap.
    when type is used then u have to create a defintion of work area for another time when internal table doesnt have headr line as
    ex:
    DATA : BEGIN OF t_vbap OCCURS 0,
    vbeln1 LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
    kwmeng LIKE vbap-kwmeng,
    netpr LIKE vbap-netpr,
    netwr LIKE vbap-netwr,
    werks LIKE vbap-werks,
    matnr LIKE vbap-matnr,
    arktx LIKE vbap-arktx,
    END OF t_vbap.
    DATA : BEGIN OF wa_vbap,
    vbeln1 LIKE vbap-vbeln,
    posnr LIKE vbap-posnr,
    kwmeng LIKE vbap-kwmeng,
    netpr LIKE vbap-netpr,
    netwr LIKE vbap-netwr,
    werks LIKE vbap-werks,
    matnr LIKE vbap-matnr,
    arktx LIKE vbap-arktx,
    END OF wa_vbap.
    if helpful reward soem points.
    with regards,
    suresh.

  • What is the difference between data base objects and runtime objects

    What is the difference between data base objects and runtime objects

    Hi raja,
    data base objects means u can have the presence of these objects in the database.So the tables,searchhelps,structures,lockobjects comes under these ones.
    Runtime objects are created and destroyed after the program ends, any changes we make to them are temporary only.
    regards,
    nagaraj
    Message was edited by: nagaraj kumar nishtala

  • Difference between Data-centric and Document-centric use

    Hi,
    Can someone suggest what exactly is the difference between Data-centric and Document-centric use and examples if any.
    Thanks in advance.
    Chaitanya

    Maybe it helps if you look at it this way...
    Document centric: document centric use of xml data is data that you always use in its complete form. If you want to use the data, then you always will retrieve it as one entity or you save it as one entity. You are not interested in the xml data / information inside this "package" / document, you are only interested in its total form. Lets say, you have an invoice which can be printed on one sheet of paper. This paper that contains you data, will always be treated in a document driven way, that is, in its total representation: information containted on a sheet of paper (document).
    Data centric. data centric use of xml, is usage of data were the main interest point is focused on only pieces of the total set of xml data within a document. So instead of being interested in the whole invoice, you only are interested in information like "amount of money to be payed" or "invoicenumber".
    Handling of XML data comes with (hidden) costs. Knowing how your data will be used, has to be used, is one of the first steps in designing you environment (and will have an big impact if you choose poorly). For instance, if you know that your data will always be handled (and must be stored) in a document driven way, then it will make sense to store it based on CLOB based XMLType storage. This will garantee best performance retrieval for your xml document. If you now that your xml data has to be stored so that it can be handled in a data centric way, then Object Relational XMLType storage. If conditions are setup properly data retrieval, inserts and updates will be more cost efficient then when based on CLOB XMLType storage.
    There are more differences and "cost markers" when or when not to use CLOB, OR or for instance Binary XML. The first two chapters of the XMLDB Developers Guide for Oracle 11g will give you a good head start making some of those decisions. Be also aware that you probably will have to make compromises. The current state of XML, for example, doesn't have the final solution yet for a uniform storage method.
    Message was edited by:
    Marco Gralike

  • Difference between Data Source & Tx Data Source

    What is the difference between Data Source & Tx Data Source in Services->JDBC ?

    "David" <[email protected]> wrote:
    >
    What is the difference between Data Source & Tx Data Source in Services->JDBC?JDBCDataSource gives you Connection Pooling on top of plain JDBC functionality.
    JDBCTxDataSource gives you participation in JTS transactions on top of JDBCDataSource
    functionality.
    So if you want the connections to participate in your EJB transactions, you must
    use JDBCTxDataSource.

Maybe you are looking for

  • I can't open Google Browser window

    I use Mac os 10.6.8 and today my computer was really slow so I decided to shut down all open programs including Google Chrome. However, after I restarted the computer, the Google Chrome browser wouldn't open. This has happened to me before several ti

  • Installed Itunes on new computer now I cant synch

    Ok - So I got a new computer and installed Itunes on it. I hooked up my existing ipod and I get a message saying my ipod is synced to another I tunes library. It says it can only be synced to one library at at time. I don't have the old computer anym

  • N97 music player upload

    I have a mac so it is difficult for me to transfer multimedia to my N97. I downloaded the multimedia transfer software but it only transfers songs to the memory. can anybody tell me how to play them in the music player???? Thanks. 

  • Add member to dimension in the outline

    <p> </p><p>I found a problam when i update a dimension using script MaxL and excecute in essmsh</p><p> </p><p>I Wrote script as follow :</p><p> </p><p>spool on to 'c:\hyperion\log.txt';<br><br>login $1 $2 ;<br><br>alter system load application 'Bank'

  • Mail inbox froze-up

    It appears that someone sent me a movie file and now my inbox will not load