Date arithmetic: how to format the result to hh24:mi:ss then subtract 2 dates
HelloI need to subtract two dates and formatting the result in the hh24:mi:ss format.
for example
Select to_number (to_date ('03.08.2009 08:10:30 ',' JJ.)) MM YYYY HH24:MI:SS')-to_date ('03.08.2009 08:06:52 ',' JJ.) MM YYYY HH24:MI:SS')) * 1440 as DiffDate
of the double
DiffDate
------------------------------------------------------------------------
3,63333333333333333333333333333333333312
Multiplication with 1440 returns the result in a few minutes. But I want to format the result (3,63333) in the hh24:mi:ss format. Is there an easy way to convert
the result of number in the date format?
Any help will be appreciated...
Rgds
JH
Hello
Subtracting two DATEs always results in a NUMBER.
You can use the NUMTODSINTERVAL function to convert the NUMBER into a string more or less like the results you want:
NUMTODSINTERVAL (to_date('03.08.2009 08:10:30', 'DD.MM.YYYY HH24:MI:SS') - to_date('03.08.2009 08:06:52', 'DD.MM.YYYY HH24:MI:SS')
, 'DAY'
)
Using SUBSTR and perhaps other string manipulation functions, turn this into exacltly what you want:
SELECT LTRIM ( SUBSTR ( NUMTODSINTERVAL ( TO_DATE ( '03.08.2009 08:10:30'
, 'DD.MM.YYYY HH24:MI:SS'
) - TO_DATE ( '03.08.2009 08:06:52'
, 'DD.MM.YYYY HH24:MI:SS'
)
, 'DAY'
)
, 2
, 18
)
, '0'
) AS hms_dif
FROM dual;
Results:
HMS_DIF
---------
00:03:38
Tags: Database
Similar Questions
-
How to format the SD card?
Android 4.0 will erase all data on my phone, right?
I want to format the SD card, too, because some setting or cache is stored on it as well. When and how should I do this?
Here's how to format the sd card
Settings > storage > unmount sd card > remove sd cardDon't forget to mark the right answer and the useful answer
-
How to display the result sqlplus in java?
I want to call sqlplus to run some commands sql in java, but how can I print the result of sqlplus?
In java code, I call sqlplus as:
Process of p;
Run the command
p = Runtime.getRuntime () .exec (commandString);
print the result of the command
InputStream inputStream = p.getInputStream ();
How to display the result of the execution?
Published by: Yi on February 26, 2012 23:41You can use ProcessBuilder. Copy the following code starts sql * more and runs the script in the variable "filename". It displays the results in the console of NetBeans.
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.File; import java.util.Map; public class test1 { public static void main (String args []) { test_script(); } public static void test_script () { String fileName = "@test_table.sql"; String sqlPath = "E:\\"; String sqlCmd = "sqlplus"; String arg1 = "user/password@sid"; -- plug in your user, password and db name String arg2 = fileName; try { String line; ProcessBuilder pb = new ProcessBuilder(sqlCmd, arg1, arg2); Map
env = pb.environment(); env.put("VAR1", arg1); env.put("VAR2", arg2); pb.directory(new File(sqlPath)); pb.redirectErrorStream(true); Process p = pb.start(); BufferedReader bri = new BufferedReader (new InputStreamReader(p.getInputStream())); BufferedReader bre = new BufferedReader (new InputStreamReader(p.getErrorStream())); while ((line = bri.readLine()) != null) { System.out.println(line); } bri.close(); while ((line = bre.readLine()) != null) { System.out.println(line); } bre.close(); System.out.println("Done."); } catch (Exception err) { err.printStackTrace(); } } } Here is the content of the script at E:\\test_table.sql
Prompt drop TABLE ANOTHER_TEST; DROP TABLE ANOTHER_TEST CASCADE CONSTRAINTS / Prompt Table ANOTHER_TEST; CREATE TABLE ANOTHER_TEST ( BATCH_SEQ NUMBER, BATCH_GROUP_ID NUMBER, STATUS_FLAG VARCHAR2(30 BYTE), OBJ_BEING_PROCESSED VARCHAR2(80 BYTE), BATCH_RUN_START_DTTM DATE, BATCH_RUN_END_DTTM DATE, CREATE_DTTM DATE, CREATE_USER VARCHAR2(30 BYTE), UPDATE_DTTM DATE, UPDATE_USER VARCHAR2(30 BYTE) ) LOGGING NOCOMPRESS NOCACHE PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT ) MONITORING / COMMENT ON TABLE ANOTHER_TEST IS 'This is a test table.' / EXIT /
-
How to format the hard duct under XP?
How to format the hard drive under XP?
Hello
You can format when reinstalling XP or installing another operating system process.
http://pcsupport.about.com/od/OperatingSystems/SS/instxpclean1.htm
See you soon.
-
How to format the hard drive and do a clean install of XP?
I have a legal windows XP profesional version to install and I need advice on how to format the hard disk, the version on it now was apparently a pirate vers.its years since I, did such things and my mind is old so I really need all the steps, a - z,.
* How can original title - I wipe my hard drive and install win XP Prof? *
Hi syynbbad,
In addition to the post of cbarnhorst, please see the following article on how to do a clean install of XP:
http://support.Microsoft.com/kb/978307
I hope this helps!
Debra
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think -
Don't know how to read the results of netstat EI s list? If I received 860592506 bytes sent from 43421482 how to convert MB? And does this mean byte received?
Hello
This shows the total number of bytes transmitted and received via the Ethernet card. This is the total of the amount of use up to this day.
This includes all the Web sites you have visited and emails you sent, etc..
You can calculate using one of the following methods:
Method 1:
860592506 / 1048576 = 820,72 MB
Method 2:
Multiply 860592506 with 9.53674316 * 10 ^-7 that will give us the result in mega bytes.
860592506 bytes = 820 MB 9MB not, accept my apology for the miscalculation.
Similarly 43421482 acroos = 40MB -
How to display the result of a java class in InputText?
Hi all
How can I get the result of the java classes to InputText or OutputText?
also everyone in the forum can road map me to deal with Java in oracle adf because I am a beginner in oracle adf
I saw a few samples in corner of oracle adf, but it is difficult for me.I use JDeveloper Version 11.1.2.3, technology of the Adf.
My question is how to return the result of java Bean InputText or OutText
Thank yousee if you want to have show some .so beans instance variable value you can have a few bean .define managed a variable as
string abc = "abc";create the getter set for her.
in the value property of inputText or OutPutText write an el as #{beanscope.managedbeanName.abc}
-
How to format the message in the response
Hi all
Please let me know how to format the message in the response.
Sorry this is not the case associated with sql, plsql. I went in the way of asking questions in the forums oracle instructions. But I did not find. Help, please...
I know this: when I write my thread I use.. to format the code ,but while replying how to include post with formatted text. Thanks, P prakash
>
Thanks for the reply, I would like to know how you included the message formatted in your answer.
Please let me know this...Hi again Prakash,
Easy - just put ">"at the beginning lines you want to quote. "
That is higher and space - when you answer, hit the double quotes in the bar
at the top of the post - last symbol to the right and it will be automatically
the post to which you want to reply.HTH,
Paul...
-
How to interpret the result of validation.
How to interpret the result of validation.
13366 [element < 7 >] [3, 4 rings] [edge < 0 > < 3 > cycle] [edge < 0 > in the < 4 > round]
-ORA-13366: incorrect combination of inner outer rings
-Cause: In Oracle Spatial geometry, the inner and outer rings do not always serve.
-Action: Make sure that the interior rings corresponding to an outside ring follow the outer ring of the orderly table.
I think it means that the rings 3 and 4 in element 7 have inside outside questions vs, but element 7 has no rings 3 or 4; There no cycles 1 and 2.
I'm using Oracle Database 11 g Enterprise Edition Release 11.2.0.2.0 - 64 bit ProductionYou can call sdo_geom.sdo_union on this geometry to fix.
It's
Update de_lec set c.lec_gcode = sdo_geom.sdo_union c (c.lec_gcode, c.lec_gcode,: tolerance)
where c.lec_gcode = '9417';There is no fix for the problem of validation still on 11.2.0.2, so you have a file a bug for it if you need this patch.
Siva
-
How to format the code in posts?
I'm a newbie, need help on how to format the code before posting, appreciate your help, thank you!Well, don't worry, you are aware now in only 5 posts. It took me a little longer to find out ;)
-
How to display the results in the order based on the value of research
Hi all
How to display the results in the slot order.
If the user makes a search with "MADONNA", I view the results as title begins with "MADONNA" first then the rest of the records.CREATE TABLE TEST( SONGID NUMBER, TITLE VARCHAR2(200)) INSERT INTO TEST(SONGID,TITLE) VALUES (10,'AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)'); INSERT INTO TEST(SONGID,TITLE) VALUES (11,'CICCONE, MADONNA (CA)'); INSERT INTO TEST(SONGID,TITLE) VALUES (12,'DALLIN, MADONNA LOUISE/STOCK'); INSERT INTO TEST(SONGID,TITLE) VALUES (13,'MADONNA'); INSERT INTO TEST(SONGID,TITLE) VALUES (14,'MADONNA (A)/ AHMADZAI, MIRWAIS (C)'); INSERT INTO TEST(SONGID,TITLE) VALUES (15,'MADONNA (CA)'); INSERT INTO TEST(SONGID,TITLE) VALUES (16,'MIRWAIS AHMADZAI, MADONNA'); INSERT INTO TEST(SONGID,TITLE) VALUES (17,'MIRWAIS (CA)/ MADONNA (CA),AHMADZAI'); INSERT INTO TEST(SONGID,TITLE) VALUES (18,'MADONNA (CA),CICCONE'); SELECT *FROM TEST WHERE INSTR (TITLE, 'MADONNA') > 0 output: SONGID TITLE 10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA) 11 CICCONE, MADONNA (CA) 12 DALLIN, MADONNA LOUISE/STOCK 13 MADONNA 14 MADONNA (A)/ AHMADZAI, MIRWAIS (C) 15 MADONNA (CA) 16 MIRWAIS AHMADZAI, MADONNA 17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI 18 MADONNA (CA),CICCONE Expected output : 13 MADONNA 14 MADONNA (A)/ AHMADZAI, MIRWAIS (C) 15 MADONNA (CA) 18 MADONNA (CA),CICCONE .. .. .. .. ...
Please let me know is possible to show the results in this order.
Kind regards
RajasekharThis can be a little more specific:
SQL> SELECT * 2 FROM TEST 3 WHERE INSTR (TITLE, 'MADONNA') > 0 4 ORDER BY INSTR (TITLE, 'MADONNA') 5 ,TITLE 6 ; SONGID TITLE -------------------- -------------------------------------- 13 MADONNA 14 MADONNA (A)/ AHMADZAI, MIRWAIS (C) 15 MADONNA (CA) 18 MADONNA (CA),CICCONE 12 DALLIN, MADONNA LOUISE/STOCK 11 CICCONE, MADONNA (CA) 17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI 16 MIRWAIS AHMADZAI, MADONNA 10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
-
Windows Desktop Search 4.0 how to format the column Date in results?
Is it possible to change the date column in the result pane of Windows Desktop Search 4.0?
It runs on a Windows 2003 Enterprise Server.
I have users who need to modify files that arrived today and yesterday, after 17:00. The date column only displays the time on files including today's date. Is there a registry setting that I can shape for this column to always display the Date and time?
Kind regards
RN
Hello
Republish the issue in the Windows Server forum
http://social.technet.Microsoft.com/forums/WindowsServer/en-us/home?Forum=winservergen
Thread Windows Date put in - form
-
How to format the data to a custom group
Hi all
I have a PivotTable with actual expenditures and Budget as some accounts and columns in the rows. Since I'm on the hierarchical column of account, I created custom groups for accounts using the component stages of selection. For example, I created a new group called Profit to combine 3 different accounts of profits and display a result row.
Now I want to format the data for the group to profit. I right-click on the Profit Group, choose to change the Group and click the Format button on the lower left corner. I add a shape, for example the borders. When I now discover the PivotTable, borders have been applied to the label of the group, so the word Profit is now defined. However, the values in the columns of actual expenditures and Budget have not a border. Don't know what Miss me, but I want both the group label and the values to be formatted in the same way.
How can I formatting the data values for the custom group?Hi user,
Expected behavior, it won't format the actual values and the Budget. Only the group will be formatted.
Kind regards
DpKa -
I would like to know if someone has worked with table Rotary testsystems and want to share an idea of how he dealt with follow-up of the results of each test result data in all the test station is in the table of rotation, so at the end of the cycle the results of good data by each DUT. There's a kind of technique used in arrays or clusters?
Any comments would be grateful.
Hi shada
There are many ways that you can store your results, such as Matthew commented that you can use an array of Clusters. I would recommend this table of cluster storage in a Global Variable that is functional to make data transfer safer and easier to climb. There are many examples on how to use them on the community.
There are a few tools in advance that you can also use to store your results as Of present value Tables (CVT).
TestStand parallel model with the "Result of processing" option enabled stores automatically all the results of your Tests.
Hope this information is useful.
-
How to get the result of these data
Hi all
I have a following data. And I need the output as follows.
If one of the Intr_num is missing so I need the output to be formatted the next row.
I tried this using the row_number() but could not able to achieve the result. Is there any other function or analysis features to use.
with t as ( select 10001 id, 5004 Intr_num from dual union all select 10002,5005 from dual union all select 10003,5006 from dual union all select 10004,5007 from dual union all select 10006,5009 from dual union all select 10007,5010 from dual union all select 10010,5013 from dual union all select 10011,5014 from dual union all select 10012,5015 from dual union all select 10013,5016 from dual union all ) select * from t; OUTPUT: Intr_num 5004 - 5007 5009 - 5010 5013 - 5016
Kind regards
SID
Hello
ROW_NUMBER is the right function to use:
WITH got_dif AS
(
SELECT intr_num
, intr_num - ROW_NUMBER () OVER (ORDER BY intr_num) AS dif
T
-WHERE... - If you need any filtering, put it here
)
SELECT MIN (intr_num) | ' - '
|| MAX (intr_num) AS intr_num_range
OF got_dif
GROUP BY dif
ORDER BY dif
;
Maybe you are looking for
-
e-mail can be disabled and TB used as a calendar only?
I had installed TB, I set my email, however, now I want to use TB as a CALENDAR only, is possible to close the tab "email"? Make a right-click only allows you to "close other tabs", to not close the email tab. I guess I could remove the email account
-
I bought this phone a week or two ago and it exceeds all my expectations so far! The battery life is amazing, the performance is good, screen and the camera are both above average. I just have a small question, because there is no update on the websi
-
Can I use a sandisk Cruzer Blade 4 GB as readyboost for windows XP Home Edition PC?
Can I use a sandisk Cruzer Blade 4 GB as readyboost for windows XP Home Edition PC?
-
I reinstalled Windows Vista Home Premium SP1 from recovery disks provided with the laptop HP. This reformats the disk and restores out of the box. When connecting to the internet: Make all Windows updates before installing the Antivirus/security soft
-
This has happened after that I had some kind of accident. Initially, I tried to restore to a system restore point that has led to the problem that I have now. I don't have an installation disc, because the files are on a partition on the hard drive a