Find the difference between two date and time
Hi friends,I wanted to find the difference between two date and time, but my qury is slightest error "invalid number."
select sql_step_num,proc_name,run_seqno,start_date,end_date,(to_char(start_date,'HH24-MI-SS') - to_char(end_date,'HH24-MI-SS') ) as ed
from eval.EVAL_RUNTIME_DETAILS
where trunc(start_date) = trunc(sysdate)
order by sql_step_num;
You try to get the feel between two char strings.
And more difference between two dates gives a NUMBER of days.
Try this:
select sql_step_num,proc_name,run_seqno,start_date,end_date,numtodsinterval(end_date-start_date,'DAY') as ed
from eval.EVAL_RUNTIME_DETAILS
where trunc(start_date) = trunc(sysdate)
order by sql_step_num;
Tags: Database
Similar Questions
-
How to find the difference between two dates in time except Sunday
Hi all
I have a table, as shown below.
I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.SQL> select * from test; TR_ID CREATE_TIME CODE -------------------------------------------------- --------------------------------------------------------------------------- ---------- S12341 05-JUN-12 12.20.52.403000 AM 1003 S12342 11-JUN-12 11.15.33.182000 AM 1003 S12342 07-JUN-12 12.00.36.573000 PM 1002 S12343 20-JUN-12 12.34.37.102000 AM 1003 S12343 15-JUN-12 11.34.27.141000 PM 1002 S12344 01-JUL-12 10.01.06.657000 PM 1002 S12344 06-JUL-12 12.01.04.188000 AM 1003 S12341 31-MAY-12 11.20.38.529000 PM 1002
For example:
TR_ID: S12344
1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
1003_Create_time: 12.01.04.188000 AM 6 July 12
1002 create time is 22:00 Sunday.
If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.
I tried the sub query after doing a search on this forum but I am not getting the desired output.
Need help to get the desired o/pSELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
Hello
If I unederstand the problem correctly, that's what you want:
WITH got_extrema AS ( SELECT tr_id , CAST (MIN (create_time) AS DATE) AS start_date , CAST (MAX (create_time) AS DATE) AS end_date FROM test GROUP BY tr_id ) SELECT tr_id , start_date, end_date -- If wanted , 24 * ( ( ( TRUNC (end_date, 'IW') -- Count -1 day for every full week - TRUNC (start_date, 'IW') ) / -7 ) + LEAST ( end_date -- If end_date is a Sunday , TRUNC (end_date, 'IW') + 6 -- consider it 00:00:00 on Sunday ) - CASE WHEN start_date >= TRUNC (start_date, 'IW') + 6 -- If start_date is a Sunday THEN TRUNC (start_date, 'IW') + 6 -- consider it 00:00:00 Sunday ELSE start_date END ) AS total_hours FROM got_extrema ;
I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.
Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
(a) 1 day is deducted for each week between start_date and end_date
(b) if End_date is a Sunday, none of the end_date himself hours are counted
(c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.
Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002} -
How to find the difference between two dates in the presentation layer
Hi gurus,
Hello to everyone. Today, I came with the new requirement.
I need to know the difference between a date and the current date in the formula column application presentation layer.by.
Thank you and best regards,
PratesHi Navin,
TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".
If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...
hope you understand...
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
Find the difference between two numbers (DBL)
Hi all
Is there a function in labview other than the subtraction function that can find the difference between the two numbers given?
Thank you
Davidson
-
How to find the difference between standard edition and standard edition one
How to find the difference between oracle database standard edition and standard edition one 64 bit
(a) using sql
(b) using the configuration/installation filesHow to find the difference between oracle database standard edition and standard edition one 64 bit
(a) using sql
Select * the option of $ v;
(b) using the configuration/installation files
opatch lsinventory-details
-
Dynamic action - Get the difference between two dates + times
I have problems a little dynamic to work action. I'm trying to get the time between two dates with the time difference.
Here is what I got (this is apex 4.0):
Two date pickers + two numbers fields (date/start/end times)
I created a dynamic action on the page who fires on the point lose focus (above points).
The real action for the DA is the body of the PL/SQL function:
When I change the values on the page, I get the following error:declare end_date DATE; start_date DATE; Begin start_date := to_char(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MON-YYYY HH:MIAM'); end_date := to_char(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MON-YYYY HH:MIAM'); :P1_HOURS := end_date-start_date; End;
AJAX call back Server error ORA-06502: PL/SQL: digital or value error: character number conversion error to set the value.
I'm guessing that there is a problem with the date formatting, but I can't make it work. Thanks in advance!Hi djston,
because you chose the dynamic action of 'Set value' with the "Body of the PL/SQL function" type you need to return the value. Try the following code
declare end_date DATE; start_date DATE; Begin start_date := to_date(:P1_START_DATE || ' ' || :P1_START_TIME, 'DD-MM-YYYY HH:MIAM'); end_date := to_date(:P1_END_DATE || ' ' || :P1_END_TIME, 'DD-MM-YYYY HH:MIAM'); RETURN (end_date-start_date)*24; End;
and P1_REQUESTED_HOURS like 'item affected. "
Concerning
Patrick
-----------
My Blog: http://www.inside-oracle-apex.com
APEX 4.0 Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolfPublished by: Patrick Wolf on January 17, 2011 10:54
-
How to tell the difference between two dates
Hello:
I have a question on how to get the difference in quantities for two dates in the replies and dashboard.
This is the scenario. I have two guests date and three columns. The first column must be the sum of the amounts for the first quick date. The second column should be the sum of the amounts for the second fast date. And the third column is the difference between the first two columns.
Basically, I'm trying to do something similar to a function of sum of two lines but trying to get the difference between the two rows. Any help to solve this problem would be appreciated.Use the COLUMN FILTERS level...
the first column with the first variable of date quick presentation of the filter
Similarly, the second column in the second variable of quick overview of date filter
Kind regards
Rambeau -
difference between two dates in the year/month/day in Obiee
Hi gurus,
I know this question have been asked and answered several times but I have a requirement that is a little different, then the previous ones.
I want to calculate the difference between two dates in OBIEE10g in year/month/day format similar to the below SQL output
SQL > select end_date, start_date,
trunc (months_between (end_date, start_date) / 12) years.
months of mod (trunc (months_between (end_date, start_date)), 12).
End_date - add_months (start_date, trunc (months_between (end_date, start_date))) days
t
Thanks in advance
SK
Search for this
"TIMESTAMPDIFF IN THE FORM OF MTHS # YEARS."
or else
To get the current mandate of employees since the date of hiring in the form of # years # mths or # year (s) # month (s)
Concat (concat (cast (TIMESTAMPDIFF (SQL_TSI_Month, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) / 12 as char),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Month (s)'))
Concat (concat (CAST (TIMESTAMPDIFF (SQL_TSI_YEAR, "Employee attributes". (((' ' Hiring last Date employee ", CURRENT_DATE) as CHAR),"Year (s)"), concat (cast (MOD (TIMESTAMPDIFF (SQL_TSI_Month,"Employee attributes". (((((' ' Hiring last Date employee ", CURRENT_DATE), 12) as char), 'Mth (s)'))
-
How do the time difference between two dates?
Hi all
I use this query to get the time difference between two dates.
Select to_timestamp ('2012-10-03 12:00 ',' YYYY-MM-DD hh)-to_timestamp ('2012-10-03 11:00 ',' YYYY-MM-DD hh) as double diff;
but do not get the correct result.
Thank youLeft KEY... Left Padding of tanks.
-
How to calculate the difference between two times by the NUMBERS
I'm so bothered by the fact that I can't understand that.
Cell B2 - 08:00
Cell C2 - 10:50
(How can cell D2 - I get this cell to calculate the difference and say 02:50?)
I know it's probably one of the most basic operations, but for the life of me I can't understand it. The cells B2 and C2 are formatted for a 24-hour clock. But if I tell the system to just subtract the two, I get "0,118. Everything I find on the forum search goes beyond what I need. Can someone help me?
Thank you
Hi sapirs,
Departure and arrival of the cells are in Date and time with Date format: no and time: 24-hour clock.
Formula in D2 (fill down)
= C2−B2
The results become a duration format, but under automatic (numbers automatically worth this format)
If you wish, you can change the cells of lasting results.
What Data Format have your result cells?
Kind regards
Ian.
-
. For example, I need to calculate the difference between a date column, 'Table_Name '. "' Column_Name ' and (Current_Date-1). I tried different ways to do this. But nothing seems to work.
Try the below formula.
Replace "Time". "" Date "with your column.
TIMESTAMPDIFF (SQL_TSI_DAY, "Time". "Date", TIMESTAMPADD (SQL_TSI_DAY-1, CURRENT_DATE))
Thank you!
-
Calculate the hours between two dates
Hello
I have a requirement to count the hours with 2 given timestamps, something like:
However, I wish it would be that simple. I just need to count the hours between two timestamps for the hours of work for example, 08:00 - 17:00, MONDAY to Friday (excluding weekends).SQL> select ((to_date('22-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss') - to_date('20-oct-2012 13:00:00','dd-mon-yyyy hh24:mi:ss'))*24) B from dual ; B ---------- 48
So lets say I have to count the hours between two dates above the result should be 18 hours not 48 (4 hours on 20/oct, 9 hours on 21/oct to 5 hours 22/oct).
How can I achieve this? Any idea will be useful.
Thank youMy query generates a list of all the hours between the start and end time, filters on the hours that are outside of the hours of work and then account for the remaining lines. Change that to partial hours must just be a case of replace the two occurrences of 1/24 with 24/01/60, then - as say you - Division COUNT (*) by 60.
There may be performance issues using techniques of generation of line like this, if you put this in a query involving the joining of several lines of other tables (for example where the dates of beginning and end are derived from several employees?) or in several days. If you don't find it then count the number of whole days (taking weekends into account) between dates and work on the partial days after that it could be better. This would probably involve a lot of statements of case (which I don't have time to test it now).
Ben
-
How to store the difference between two timestamps as a number?
Hello
I need to find the difference between 2 variables of timestamp and the result will be stored as a number in minutes?
as
declare
timestamp (7) of the fir_timestamp: = 1 January 2012 13:30 ';
timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 ';
c number;
Start
c:=((sec_timestamp-fir_timestamp)/(24*60));
dbms_output.put_line (c);
end;962813 wrote:
declare-fir_timestamp timestamp (7): ='01 - jan - 2012 13:30 ';
timestamp (7) of the sec_timestamp: = 1 January 2012 14:00 '; Incorrect type declarationfir_timestamp timestamp: = 1st January 12 01.30.00.000000 PM';
sec_timestamp timestamp: = 1st January 12 02.00.00.000000 PM';
c number;
Start
c: = ABS ((extrait (HEURE de sec_timestamp) - extract (fir_timestamp TIME)) * 60) +.
ABS ((extrait (MINUTE de sec_timestamp) - extract (fir_timestamp MINUTE)));
dbms_output.put_line (' interval Min Total:-' | c);
end;
/
declare
*
ERROR on line 1:
ORA-01830: date format picture ends before converting all of the input string
ORA-06512: at line 6Follow what Paul has done...
In fact, you do not need timestamp, date data type is enough
SQL> declare 2 fir_timestamp date := 3 to_date('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss'); 4 sec_timestamp date := 5 to_date('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss'); 6 c number; 7 begin 8 c:= round((sec_timestamp-fir_timestamp)*24*60); 9 dbms_output.put_line(c); 10 end; 11 / 30 PL/SQL procedure successfully completed.
If you want to place on timestamp
SQL> declare 2 fir_timestamp timestamp := 3 to_timestamp('01-jan-2012 13:30:00','dd-mon-yyyy hh24:mi:ss'); 4 sec_timestamp timestamp := 5 to_timestamp('01-jan-2012 14:00:00','dd-mon-yyyy hh24:mi:ss'); 6 c number; 7 begin 8 c:= round(( 9 to_date(to_char(sec_timestamp,'ddmmyyyyhh24miss'), 10 'ddmmyyyyhh24miss')- 11 to_date(to_char(fir_timestamp,'ddmmyyyyhh24miss'), 12 'ddmmyyyyhh24miss') 13 )*24*60); 14 dbms_output.put_line(c); 15 end; 16 / 30
-
What is the difference between Foglight JavaEE and Foglight JMX monitoring?
Hello
I have a plan to monitor the 6.1.0.17 WebSphere Application Server (32 bit) and 7.0.0.5 (64-bit)
But I understand not all Foglight for JavaEE and Foglight for JMX.
Foglight for JavaEE or Foglight for JMX is able to monitor WebSphere?
What is the difference between Foglight JavaEE and Foglight JMX monitoring?
Thanks in advance
Jeans
Just to add to the excellent answers already posted.
We have 2 agents which allows you to monitor Java:
1. a JavaEE agent that runs inside the JAVA virtual machine and the information of both JMX and instrumentation.
This Agent will give you JMX information like information of JVM (use of the bunch, son etc.), of the Application and server availability information and other information of JMX/PMI (connections pools, pools of ejb, servlets, jsp, JCA and more).
Java EE & # 039agent also gives you information of the instrumentation - RFA count and response time, exceptional output and timeout information, distribution of queries (App/DB, component technology, server, application failure), object tracking, transaction flow and stransactional between servers and data sources) and ask traces (the ability to see the trees of the RFA at the method level to know where things are slow/stuck).
2 JMX agent is running outside the JVM but can run on the same computer or on a remote computer, this agent requires access active, JMX. This agent gives you information JVM, availability server/applications, as well as some data as the application server published using JMX (pools of connections, JCA, EJB, servlets, etc.). The JMX agent also gives you the ability to see a list of the mbeans, get the data they expose (javaEE agent gets only a predefined list (same list that is used as a template for the application servers in the JMX agent)).
Hope this helps
Golan
-
What is the difference between Unicast RPF and Reverse Path Forwarding?
I am confused between Unicast RPF and Reverse Path Forwarding function.
What is the difference between Unicast RPF and Reverse Path Forwarding?
Because they have all two please check the address of the source of each package before sending it to the destination too?
Reverse Path Forwarding is used only when the network want to build a tree shared multicast communication and then we must use Unicast RPF after creation of the shared tree?
The mechanism of the RPF is mainly used to ensure no loop of routing traffic.
As you probably already read, it does by ensuring that his route to the source address of a packet received is accessible via the same interface that the packet is entered in the. Think of the notion of "root port" in STP. all root ports are similar to the root, sunflower follow the Sun. Therefore, it is naturally a loop prevention mechanism.
With multicast traffic, it is quite likely to create multiple loops of routing the nature of 'destination' traffic. For this reason, using a mechanism as the RPF to ensure you are on the "road to the root" (to say) to the source originating multicast traffic. Otherwise if you're not then you either receive this traffic route in a loop, or a suboptimal path.
uRPF works essentially the same way, except that it is done for unicast traffic instead. Now with unicast traffic your flow is from a source and directs to a single destination. Given that, as the fact that you are using a dynamic routing algorithm (which allows to select the path to a destination), you can have loops of your network for unicast traffic flow routing; of course there may be exceptions to pitfalls of configuration route redistribution.
However RPF when it is applied to traffic unicast can add another advantage, and it's verification IP source. That's why we can use it as a security mechanism to ensure that data are from where it is supposed to come.
On the limit of the L2, you then have mechanisms such as guard source IP to ensure that the correct host is not usurpation of their IP address.
By analogy RPF can be used for checking at source for multicast traffic, and it is intrinsically that however, the most important role is so that it can be used to guarantee without loop routing of multicast traffic.
I hope that helped clear things upwards and not confused you any more with all this.
Maybe you are looking for
-
My browser reports a I'm in Burbank - I'm in Las Vegas - how can I change?
My browser is identified by other sites like me being in Burbank - I'm in Las Vegas - how to fix this?
-
Failed to load messages from LinkedIn or notice.
Since the last update of Firefox, I can open is more no message on my Samsung GalaxyIII LinkedIn group. Help?
-
How to disable the placeholder text in the URL from the navigation bar and search fields?
Everytime I open a new tab (often, the homepage is set to blank) I watch 'Go to site' in the navigation bar. The search field shows the name of the active search engine until the text is registration. All I want is to be able to do is disable the pla
-
She gets the following message appears: "error SMTP from remote mail server after the mail from: * address email is removed from the privacy * SIZE = 8736: accommodate the aln - mailrelay.att [12.102.252.75] .net: 521 - 67.212.91.61 blocked by sbc:bl
-
Good beginners (Dummies) Guide 4.1 android?
Hi all Last year, I bought a HP Slate 7 2800 for my mother-in-laws, who do little or no computer experience and were looking for something simple email and a bit of web browsing. I previously loaded all the extra apps I thought they might need, and a