Need difference in date in hh24:mi:ss format

Have 2 date fields in a table. Need the difference between the dates in hh:mi:ss format
Here is my table:
create table test(
ID number,
StartDate date,
FinishDate date,
DateDifference varchar2(13));
Here is my record:
insert into test values (1, to_date('01/21/2010 10:05:10','mm/dd/yyyy hh:mi:ss'), to_date('01/21/2010 11:05:10','mm/dd/yyyy hh:mi:ss'), NULL);
Want to populate the DateDifference field as difference between FinishDate and StartDate which in this case would be: 01:00:00. Format needs to be hh:mi:ss.

Hi,
As long as the differences are less than 24 hours, you can say somehting like:
UPDATE     test
SET     DateDifference = TO_CHAR ( TRUNC (SYSDATE) + ( FinishDate
                                               - StartDate
                     , 'HH24:MI:SS'
;For longer amounts of time, you can extract part of an INTERVAL DAY TO SECOND:
UPDATE     test
SET     DateDifference = SUBSTR ( NUMTODSINTERVAL ( FinishDate - StartDate
                                          , 'DAY'
                    , 7
                    , 13
Thanks for posting the sample data in such a nice form!
Even in a simple job it helps.
Edited by: Frank Kulash on Jan 22, 2010 2:15 PM
Had better idea for difference >= 24 hours.

Similar Messages

  • Difference between date in 'HH:MI:SS.FF' format

    Hi All,
    I am on Oracle 10G.
    I have small doubt about How to Calculate the Difference between two date in formate 'HH:MI:SS.FF'?
    Sample data
    to_date('14-Aug-2007 11:07:42','DD-Mon-YYYY HH24:MI:SS.FF')
    to_date( '14-Aug-2007 10:02:30','DD-Mon-YYYY HH24:MI:SS.FF')
    Thanks
    Vivek

    Firstly, you cannot specify fractional seconds for the DATE type so the '.FF' format model element is illegal for this datatype.
    If you're using DATE you can do something like this:
      1  select to_char(hours, 'fm00')||':'||
      2  to_char(trunc(minutes), 'fm00')||':'||
      3  to_char(round((minutes - trunc(minutes))*60), 'fm00') as formatted
      4  from (
      5     select trunc(hours) as hours
      6     , (hours - trunc(hours))*60 as minutes
      7     from (
      8        select (
      9          to_date('14-AUG-2007 11:07:42','DD-MON-YYYY HH24:MI:SS')
    10        - to_date('14-AUG-2007 10:02:30','DD-MON-YYYY HH24:MI:SS')
    11        )*24 as hours
    12        from dual
    13     )
    14* )
    SQL> /
    FORMATTED
    01:05:12Might be easier to use INTERVALs and TIMESTAMPs though. Unfortunately there's no TO_CHAR for INTERVALS so you need to do something like this:
      1  select
      2    to_char(extract(hour from diff), 'fm00')||':'||
      3    to_char(extract(minute from diff), 'fm00')||':'||
      4    to_char(extract(second from diff), 'fm00') as formatted
      5  from (
      6     select
      7       to_timestamp('14-AUG-2007 11:07:42','DD-MON-YYYY HH24:MI:SS.FF')
      8     - to_timestamp('14-AUG-2007 10:02:30','DD-MON-YYYY HH24:MI:SS.FF')
      9     as diff
    10     from dual
    11* )
    SQL> /
    FORMATTED
    01:05:12cheers,
    Anthony

  • I need to import data from a CSV file to an Oracle table

    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.
    As an example, my target database is HH910TS2, server is ADDb0001, my dB login is em/em, the Oracle table is AE1 and the CSV file is AECSV.
    Any ideas / help ?

    And just for clarity, it's good to get your head around some basic concepts...
    user635625 wrote:
    I need to import data from a CSV file to an Oracle table. I'd prefer to use either SQL Developer or SQL Plus code.SQL Developer is a GUI front end that submits code to the database and displays the results. It does not have any code of it's own (although it may have some "commands" that are SQL Developer specific)
    SQL*Plus is another front end (character based rather than GUI) that submits code to the database and displays the results. It also does not have code of it's own although there are SQL*Plus commands for use only in the SQL*Plus environment.
    The "code" that you are referring to is either SQL or PL/SQL, so you shouldn't limit yourself to thinking it has to be for SQL Developer or SQL*Plus. There are many front end tools that can all deal with the same SQL and/or PL/SQL code. Focus on the SQL and/or PL/SQL side of your coding and don't concern yourself with limitations of what tool you are using. We often see people on here who don't recognise these differences and then ask why their code isn't working when they've put SQL*Plus commands inside their PL/SQL code. ;)

  • 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

  • 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

  • I just bought an unlocked Iphone 4s and I wanna know if I need to take an Iphone plan or a 30$ plan could be enough and also if I only use it on wi-fi do I need to have datas in my plan?

    I just bought an unlocked Iphone 4s and I wanna know if I need to take an Iphone plan or a 30$ plan could be enough and also if I only use it on wi-fi do I need to have datas in my plan?

    The iPhone is designed to always have an internet connection as long as there is an available wi-fi network you have access to, or cellular reception. MMS requires a data connection with your cell phone carrier, which can't be exchanged over wi-fi. If your carrier supports visual voicemail with the iPhone, visual voicemail messages are downloaded to the iPhone via the carrier's cellular data or internet network only, not via wi-fi. If you ever need to make use of the Find My iPhone feature, it will be worthless without a data connection with your carrier's cellular network.
    If you don't plan on having a data plan or you can't afford it, your money was wasted purchasing an iPhone. This likely makes no difference since most carriers require a data plan with the iPhone.

  • Difference between Data carrier type and Data carrier??

    Hi experts,
    Could you please explain me the difference between Data carrier type and Data carrier with an example??
    Regards,
    Kiran T

    hi Kiran,
    Data carrier is to achive communication between server and user front end. We can define one data carrier type along with path as default for all or seperate data carriers type for specific users in define data carrier in SPRO. This defined data carriers again we assign to application in defining network for workstation application in SPRO.
    By using data carrier we can upload to & download originals from server. We can change and print the documents from server.
    Please award pts if its useful / need further information.
    Pramod

  • Difference between Data Grid and Data Forms

    Hi all,
    What is the difference between data grid and data forms.

    Data entry forms are pre defined and are generally used to manually input data into reporting (financial statement) schedules.
    They can also be used for reviewing purposes and it gives users a presentable / and consistent format to view data in Hyperion.
    Data grids are the equivalent of pivot tables in excel. It should be used for ad hoc purposes to view / analyse data in whatever form you choose. The user has the flexibility to choose what they see in the rows, columns and page dimensions.
    One of the main differences between data entry forms and data grids is that you can’t export data grids to excel whereas you can with data entry forms. Other differences are:
    1. Run consolidation, translation, promotion from data grids but not in data entry forms.
    2. You can link other data entry forms to a data entry form
    3. Data entry forms offer greater formatting options than in data grids i.e. colours, fonts, bold, italics.
    At the end of the day, they are similar and there is no reason why you can’t have (use) both. It all depends on your local needs on how best you use both.
    I hope above information helps.

  • What is the difference  between  data file  & control file

    what is the difference  between  data file  & control file

    Dear Deba s
    Control file
    Every Oracle Database has a control file, which is a small binary file that records the physical structure of the database. The control file includes:
    The database name
    Names and locations of associated datafiles and redo log files
    The timestamp of the database creation
    The current log sequence number
    Checkpoint information
    For more info look into these
    [Control File Basic|http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14231/control.htm#i1006143]
    Data File
    You manage Data File in your Oracle database as part of Space Management. You can extend, create, drop, and alter tablespaces.
    You especially need to avoid tablespace overflow, which is when a tablespace runs out of freespace in the allocated file or files. This happens when an object requires a new extent but there is either no freespace or insufficient freespace in the tablespace
    For more info look into these links
    [Data files |http://help.sap.com/saphelp_nw04/helpdata/en/98/5dd5890f32274aa884e45e736752a2/frameset.htm]
    http://help.sap.com/saphelp_nw04/helpdata/en/98/5dd5890f32274aa884e45e736752a2/frameset.htm
    Hope it helps you,Revert me back if you have any queries
    Assign points if helpful
    Regards
    Bala

  • I need to transfer data from my old iphone to my new iphone and I cannot turn off Find my iphone

    I need to transfer data from my old iphone to my new iphone and I cannot turn off Find my iphone as my icloud password is incorrect.  I have reset this several times and also cleared cookies history etc.  none of the above makes a difference.  Any ideas?

    The ONLY thing you can do to turn off Find My iPhone is to have the correct password. There is no way around it. You can get help with the password: If you forgot your Apple ID password
    If none of those methods are possible: Apple ID: Contacting Apple for help with Apple ID account security

  • Need to convert  Date from calendar to String in the format dd-mom-yyyy

    Need to convert Date from calendar to String in the format dd-mom-yyyy+..
    This is absolutely necessary... any help plz..
    Rgds
    Arwinder

    Look up the SimpleDateFormat class: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    Arwinder wrote:
    This is absolutely necessary... any help plz..For you maybe, not others. Please refrain from trying to urge others to answer your queries. They'll do it at their own pace ( if at all ).
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • What cable do I need to transfer data direct from my iMac to my macbook pro

    What cable do I need to tranfer data direct from my iMac to my MacBook pro?

    Generally, Ethernet or FireWire.
    (71181)

  • I need to copy data from a table in one database (db1) to another table in

    Hi
    I need to copy data from a table in one database (db1) to another table in another database (db2).
    I am not sure if the table exists in db2,,,if it doesnot it needs to be created as well data also needs to be inserted...
    How am I supposed to this using sql statements..?
    I shall be happy if it is explained SQL also...
    Thanking in advance

    How many rows does the table contains? There are manyway you can achieve this.
    1. export and import.
    2. create a dblink between two databases and use create table as select, if structure doesnot exists in other database, if structure exists, use, insert into table select command.
    example:
    create a dblink in db2 database for db1 database.
    create table table1 as select * from table1@db1 -- when there is no structure present
    -- you need to add constraints manually, if any exists.
    insert into table1 select * from table1@db1 -- when there is structure present.
    If the table contains large volume of data, I would suggest you to use export and import.
    Jaffar

  • I need to pass data from an Access database to Teststand by using the built in Data step types(open data

    base /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1i need to pass data from an Access database to Teststand by using the built in Data step types(open database /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1
    When I tried the same thing on another cmputer the same thing
    happend
    appreiciate u"r help

    base /open SQL Statement etc) the first time i defined the system everything was fine but when i changed the Database (using M.S.Access) the " open SQL Statement" it would show the tables but not thier columns ,I"m using win98 sec edition / Teststand 1.0.1Hello Kitty -
    Certainly it is unusual that you can still see the tables available in your MS Access database but cannot see the columns? I am assuming you are configuring an Open Statement step and are trying to use the ring-control to select columns from your table?
    Can you tell me more about the changes you made to your file when you 'changed' it with MS Access? What version of Access are you using? What happens if you try and manually type in an 'Open Statement Dialog's SQL string such as...
    "SELECT UUT_RESULT.TEST_SOCKET_INDEX, UUT_RESULT.UUT_STATUS, UUT_RESULT.START_DATE_TIME FROM UUT_RESULT"
    Is it able to find the columns even if it can't display them? I am worried that maybe you are using a version of MS Access that is too new for the version of TestSt
    and you are running. Has anything else changed aside from the file you are editing?
    Regards,
    -Elaine R.
    National Instruments
    http://www.ni.com/ask

Maybe you are looking for

  • Bluetooth paired and connected, but not showing up in device list

    I have a iphone 4s and a plantronics discovery 975.  It was working fine, I don't recall doing any updates...  But now, it's showing paired and connected, but when I make a call, it's not connecting and doesn't sho up in the the device options - only

  • Using Java Beans in Java Server Pages

    Can we not use a method of Java Bean in a Java Server Page ? I am trying to retrieve the user email from a java bean method "getUserEmail". I am instantiating the class, but when I try to use that in JSP tags, I am getting an error. <jsp:useBean clas

  • How to recording from MW600

    Hi I would like to ask if I can recording the calls, FM radio and sound from mic with MW600 I use XPERIA X10

  • SWF from swfLoader not unloading - how to resolve?

    Hi,  My swfs unload properly when I run the application in the Flashbuilder environment, but in the release build on the web, they do not  I wonder if I need to test for the swf to unload before I close the custom popup box? I load the swfs like this

  • How to transfer Elements 8 to new mac computer

    Do I really have to buy a completely new version of Elements, or is there some way to transfer from Mac 10.6.8 to 10.9.5?