Calculate the hours between 2 business days
Hi all
Do a complex calculation on the days I do not know how to achieve this.
Here is my case:
I have a week of work with hours of work.
Then there's this delivery time sheet for how long should be set an order ready to be delivered:
Order1: max 5 hours of work
Order2: max 8 working hours
Order3: max 16 hours of work
When an order is placed, the time of the order is recorded, and when an order has been set in ready to be delivered, this time is also registered.
How to calculate the time difference between the time where an order has been placed and the time where the order has been on loan. Thereby also taking into account the working days and hours of work.
Example: type order1 order was placed Tuesday at 15:00.
Order has been fixed loan Wednesday at 14:00
This means that to fix this ready order lasts 7 hours, which means that it is 2 hours time.
CREATE TABLE REF_WORKDAYS ( "WERKDAG" VARCHAR2(15 ) NOT NULL ENABLE, "SOORT_WERKDAG" VARCHAR2(15 ) NOT NULL ENABLE, "BEGIN_TIJD" VARCHAR2(10 ) NOT NULL ENABLE, "EIND_TIJD" VARCHAR2(10 B) NOT NULL ENABLE, )
Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Monday','WORKINGDAY','08:00','16:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Tuesday','WORKINGDAY','08:00','16:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Wednesday','WORKINGDAY','08:00','16:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Thursday','WORKINGDAY','08:00','16:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Friday','WORKINGDAY','08:00','16:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Satrurday','WORKINGDAY','08:00','14:00'); Insert into REF_WORKDAYS (WERKDAG,SOORT_WERKDAG,BEGIN_TIJD,EIND_TIJD) values ('Sunday','NOT-WORKINGDAY','08:00','16:00'); COMMIT;
create table glas_order (order_id number , order_desc varchar2(100) not null , order_type varchar2(10) not null , order_date date not null , order_ready date );
Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (1,'order bla','Order1',to_date('07-APR-15 09:00','DD-MON-RR HH24:MI'),to_date('08-APR-15 12:00','DD-MON-RR HH24:MI')); Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (2,'order nice','Order1',to_date('14-APR-15 10:00','DD-MON-RR HH24:MI'),to_date('16-APR-15 16:00','DD-MON-RR HH24:MI')); Insert into GLAS_ORDER (ORDER_ID,ORDER_DESC,ORDER_TYPE,ORDER_DATE,ORDER_READY) values (3,'order ugly','Order2',to_date('18-APR-15 13:00','DD-MON-RR HH24:MI'),to_date('21-APR-15 09:00','DD-MON-RR HH24:MI')); COMMIT;
Thank you
Diana
Select
I like order_id
such as length d
order_type
d decode(order_type,'Order1',5,'Order2',8)
overtime
of glas_order o
model
Reference r on
(select
WERKDAG w
begin_tijd b
e eind_tijd
, (to_date (eind_tijd, 'HH24') - to_date (begin_tijd, 'HH24')) * 24 hard
of ref_workdays
where soort_werkdag = "WORKINGDAY")
dimension (w)
measures (b, e, hard)
main m
partition of (order_id I)
size of (0 n)
measures (0d, order_date, order_ready, cast (null as varchar2 (10)) as wday, order_type)
iterate (1e6) rules until (iteration_number > = trunc(order_ready[0]) - trunc(order_date[0])))
WDAY [0] = to_char (order_date [0] + iteration_number, 'FMDay', 'NLS_DATE_LANGUAGE = ENGLISH')
, d [0] = d [0] +.
case
When trunc(order_date[0]) = trunc(order_ready[0]) - beginning and ready same day
then presentv (r.b [wday [0]],)
less (largest (order_ready [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')), to_date (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))
-bigger (to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI'), least (order_date [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))))
0) * 24
When order_date [0] + iteration_number = order_date [0] - first day
then presentv (r.b [wday [0]],)
TO_DATE (to_char (order_date [0], 'YYYYMMDD') | r.e [WDAY [0]], 'YYYYMMDDHH24:MI')
-bigger (order_date [0], to_date (to_char (order_date [0], 'YYYYMMDD') | r.b [WDAY [0]],'YYYYMMDDHH24:mi'))))
0) * 24
When trunc(order_date[0]) + iteration_number = trunc(order_ready[0]) - last day
then presentv (r.b [wday [0]],)
less (order_ready [0], to_date (to_char (order_ready [0], 'YYYYMMDD') | r.e [WDAY [0]],'YYYYMMDDHH24:mi'))))
-to_date (to_char (order_ready [0], 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')
0) * 24
of another nvl (r.dur [wday [0]], 0)
end
)
ORDER_ID | DURATION | ORDER_TYPE | OVERTIME |
---|---|---|---|
1 | 11 | Order1 | 6 |
2 | 22 | Order1 | 17 |
3 | 10 | Order2 | 2 |
Rewrittten party rules for readability purposes (more resources)
measures (0d, order_date, order_ready, cast (null as varchar2 (10)) as to_date (null), (null) to_date, bd, order_type, wday ed)
iterate (1e6) rules until (iteration_number > = trunc(order_ready[0]) - trunc(order_date[0])))
WDAY [0] = to_char (order_date [0] + iteration_number, 'FMDay', 'NLS_DATE_LANGUAGE = ENGLISH')
, comics [0] = to_date (to_char (order_date [0] + iteration_number, 'YYYYMMDD') | r.b [WDAY [0]], 'YYYYMMDDHH24:MI')
, ed [0] = to_date (to_char (order_date [0] + iteration_number, 'YYYYMMDD') | r.e [WDAY [0]], 'YYYYMMDDHH24:MI')
, d [0] = d [0] +.
case
When trunc(order_date[0]) = trunc(order_ready[0]) - beginning and ready same day
then presentv (r.b [wday [0]],)
less (largest (order_ready [0], [0] bd), ed [0])
-Greatest (BD [0], least(ORDER_DATE[0],ED[0]))
0) * 24
When order_date [0] + iteration_number = order_date [0] - first day
then presentv (r.b [wday [0]],)
ED [0]
-Greatest(ORDER_DATE[0],BD[0])
0) * 24
When trunc(order_date[0]) + iteration_number = trunc(order_ready[0]) - last day
then presentv (r.b [wday [0]],)
least(order_ready[0],ED[0])
-bd [0]
0) * 24
of another nvl (r.dur [wday [0]], 0)
end
)
Jubilee should be Saturday I guessed.
Tags: Database
Similar Questions
-
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 calculate the hours between two dates by the numbers
If I update 09:00 start time 17:00 end time of shift in C3 and B3, how to use a D3 formula to calculate the number of hours between the two? Then I can just copy down the lines for nth years...
It is a spreadsheet of the part-time staff payroll.
I'm sure that a lot of people out there have done that.
Help, please.
Thank you.
Eddie
What program of worksheet that you are using? Since you have a newer iMac running El Capitan, I can safely assume that you use NOT AppleWorks, which is a Power PC application that can run on any OS newer than the snow leopard, OS X 10.6.8.
If you use numbers, try to repost your question in numbers for Mac forum. If you use Microsoft Excel, try posting in the Microsoft forums. LibreOffice also has community support.
-
Need help to calculate the difference between times
Hi all
I have two fields that stores just the hour in 24-hour ex: 08:00 and 20:00 now I want to calculate the difference between two times
Kindle help me
Thanks for your help
Thank you
RaviHello
diiference in hours
SQL> WITH T AS (SELECT '08:00' ST_TIME, '20:00' END_TIME FROM DUAL) 2 SELECT (TO_DATE (END_TIME, 'HH24:MI') - TO_DATE (ST_TIME, 'HH24:MI')) * 24 DIFF_HOURS 3 FROM T; DIFF_HOURS ---------- 12 SQL>
G.
-
. 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!
-
How can I get the lines for the date between 2 different days
Hi all,
How can I get the lines for the date between 2 different days.
Sample data:
Table name: Articles
Title start_date end_date
Heading1 08-22-2011 2011-09-11
2011-08-01-2011-09-01 Title2
Title 3 2011-08-21 08-21-2011
title4 2011-08-28 2011-09-11
Result will be:
Title start_date end_date
Heading1 08-22-2011 2011-09-11
2011-08-01-2011-09-01 Title2
title4 2011-08-28 2011-09-11
This is my example query:
SELECT * FROM items WHERE trunc (es.date_start) > = TO_DATE('2011-08-22', 'YYYY-MM-DD') AND trunc (es.date_end) < = TO_DATE ('2011-08-28', 'YYYY-MM-DD')
but I can not get the expected results. Any help would be much appreciated.
Thanks in advancenot read your question properly before...
Please try this
Select * FROM items
WHERE (TO_DATE ('2011-08-22', 'YYYY-MM-DD') between TRUNC (es.date_start))
AND TRUNC (es.date_end)) OR
(TO_DATE ('2011-08-28', 'YYYY-MM-DD') between TRUNC (es.date_start))
AND TRUNC (es.date_end)) -
FormCalc - how to calculate the difference between the two fields datetime in hh: mm?
Hello!
I am building a form of time sheet in which I need to calculate the difference between the start and end times and present the result.
I'm trying to do with FormCalc but if it is easier with JS is ok too.
So that's what I did on the total field, by using the calculate on a NUMERIC field called decimalValue event:
elapsed = Time2Num (endTime.formattedValue, "HH: mm")-Time2Num (startTime.formattedValue, "HH: mm")
And then I tried to convert a time field:
Total = decimalValue.rawValue;
$.formattedValue = Num2Time (total, "HH: mm")
Well, it doesn't work, it gives me crazy results in the datetime (total) field. If I type 09:00 and 09:30, the final result is... 22:30. Huh?
Please, could someone help me understand how this thing works?
Thanks a lot for the tips!
Marcos
Hi Marcos,
Here are some examples:
https://Acrobat.com/#d=kCPIgVkd09qrx6h-WRXxbQ
https://Acrobat.com/#d=EsWqBMBt3sgEXnMSsK5pRA
Hope that helps,
Niall
-
Calculate the difference between the subtotals
I'm working on a simple report that looks like this:
EmployeeID EmployeeName Date salary wages
1234 Tom June 1, 2009 $2000.00
2345 harry $2400,00 June 1, 2009
3456 sally $3000.00 June 4, 2009
Partial total salary: $7400,00
Advances of salary Date EmployeeID EmployeeName
2345 harry $1000.00 may 15, 2009
3456 sally $750.00 may 15, 2009
Advances subtotal: $1750,00
Total: $5650,00
Is there any function in Discoverer, which calculates the difference between subtotals and the poster as a total. Please advise if you can create a named for this sum calculation?
Published by: user1049091 on August 6, 2009 11:33
Published by: user1049091 on August 6, 2009 12:38Hello
Not really possible. You the best approach is probably to create a named calculation that contains the difference: for example
Decode (salary_type, 'Pay', 'Progress', - wages)
Then create a total on this calculation. You can often hide the calculation itself in terms of formatting and white text on white background.
Rod West
-
Count the hours between the times of the day
Hello
It is a timesheet, calculation of payment:
I'm trying to find a way to calculate how many hours is between two specific times of the day.
I enter a start time and an end time (in 2 different items), I calculate the number of hours that is. What I can understand.
Then I need to know how many hours is between 16:00 and 22:00.
The reason is that there is an additional extra payment for those hours.
So: "payment on time' X ' total hours work in a day ' + 'bonus' X ' hours between 16 and 22" = "total wages for a day" "»
Thank you
Enter the full date and time in columns A and B (for example ' 12 Sep 2016 8:00 AM "or you like the what ever valid date time value):
C2 = B2−A2
D2 = C2−DURATION (0, 0, 24 × MAX (TIMEVALUE "(04:00 PM)") −TIMEVALUE (A2), 0)) −DURATION (0, 0, 24 × MAX (TIMEVALUE (B2) −TIMEVALUE (' 22:00 "" "), 0))
Select cells C2 and D2, copy
Select cells C2 at the end of column D, dough
If you prefer the values in column D as decimal hours use the formula:
dur2hours (D2)
or replace the formula earlier as follows:
D2 = dur2hours (C2−DURATION (0, 0, 24 × MAX (TEMPSVAL ("04:00 PM") −TIMEVALUE (A2), 0)) −DURATION (0, 0, 24 × MAX (TIMEVALUE (B2) −TIMEVALUE (' 22:00 "" "), 0)))
-
How to find the hours between two times
Hai All
I had a problem I need to calculate work time
For example
Respondent outtime
0815 1715
So I need to calculate a time between these two times
How can I do using function for 100 our
Concerning
Srikkanth.MHello
use the below the update statement.
update dail_att set wtime = extract(hour from (to_date(outtime,'HH24:MI')-to_date(intime,'HH24MI')) day to second);
Solution of the sample...
PRAZY@11gR1> desc dte; Name Null? Type ------------------- -------- -------- INTIME VARCHAR2(4) OUTTIME VARCHAR2(4) HRS NUMBER PRAZY@11gR1> select * from dte; INTIME OUTTIME HRS ---------- ---------- ---------- 0815 1715 0900 1800 0830 1630 Elapsed: 00:00:00.00 PRAZY@11gR1> update dte set hrs = extract(hour from(to_date(outtime,'HH24MI')-to_date(intime,'HH24MI')) day to second); 3 rows updated. Elapsed: 00:00:00.01 PRAZY@11gR1> select * from dte; INTIME OUTTIME HRS ---------- ---------- ---------- 0815 1715 9 0900 1800 9 0830 1630 8 Elapsed: 00:00:00.00
Kind regards
PrazyPublished by: Prazy on March 24, 2010 12:43
-
How to calculate the difference between 2 dates, but with interruptions and stops between
Hello
How can I calculate the difference in minutes between 2 dates but taking into account the existence of a table in the Appendix, so if between start_date and end_date arguments, there is no 'work time' then this part of the time will not be included in the total difference.
Records of the time table example:
Time_configuration start_hour end_day end_hour 2 19:00 3 07:00 3 19:00 4 07:00 so for example first record said that on Monday you start at 19:00 and leave the next day at 7:00 and then save the same sort of thing.
There is an event that I want to track how many minutes lasted. for example, this event began the day 2 at 19:00 and ended the day 3 at 21:00
Theoretically, this event really lasted: 840 minutes. This 840 minutes are within the limits of the annex.
Thanks in advance.
The storage of the dates not as data type DATE in most cases is bad design. In addition, how do you know what day of the date is 2 at 19:00? East - Monday 2 November 2015 or Monday, March 7, 2016? It is the same for the event. In any case, assuming that both calendar and events don't extend over several weeks:
According to schedule)
Select time_configuration 2, 19:00 ' start_hour, end_day 3,' 07:00 ' end_hour of all the double union
Select 3, 19:00 ', 4,' 07:00 ' double
),
event like)
Select event_id 1, time_configuration 2, 19:00 ' start_hour, end_day 3: 21:00 ' end_hour of the double
)
Select e.event_id,
Sum)
less (e.end_day + to_date (e.end_hour, 'HH24'), s.end_day + to_date (s.end_hour, 'hh24:mi')).
greater (e.start_day + to_date (e.start_hour, 'HH24'), s.start_day + to_date (s.start_hour,'hh24:mi'))))
) * 24 * 60 minutes
Appendix s,
e event
where e.start_day + to_date(e.start_hour,'hh24:mi')< s.end_day="" +="">
and e.end_day + to_date(e.end_hour,'hh24:mi') > s.start_day + to_date(s.start_hour,'hh24:mi')
E.event_id group
/EVENT_ID MINUTES
---------- ----------
1 840SQL >
SY.
-
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.
-
Calculate the difference between AM and PM time
I use a form and I want to have the time between two times calculated. This part works - but I have problems getting the data after that contribution has been calculated.
When you enter a time in the format hh: mm tt - I so that it has calculated and output in the format hh: mm already. He does not accept this entry however - just trying to use everything that is initially formatted. Currently, this is how I capture the data of these two areas, I need to take data. I can take this and people have to use military time, but I'd rather just take input in the format hh: mm tt.
var hrsStart = parseInt(this.getField("sTime").value.split(":")[0]);
var minStart = parseInt(this.getField("sTime").value.split(":")[1]);
var hrsEnd = parseInt(this.getField("stTime").value.split(":")[0]);
var minEnd = parseInt(this.getField("stTime").value.split(":")[1]);
That's how I'm calculation of data entry in the two fields.
var time = this.getField("stTime");
var hours = Number(time.match(/^(\d+)/)[1]);
var minutes = Number(time.match(/:(\d+)/)[1]);
var AMPM = time.match(/\s(.*)$/)[1].toLowerCase();
if (AMPM == "pm" && hours < 12) hours = hours + 12;
if (AMPM == "am" && hours == 12) hours = hours - 12;
var sHours = hours.toString();
var sMinutes = minutes.toString();
if (hours < 10) sHours = "0" + sHours;
if (minutes < 10) sMinutes = "0" + sMinutes;
this.getField("stTime").value = (sHours +':'+sMinutes);
My answer of Validation?
I also tried to make getHours / getMinutes, but values come up unresolved.
I will accept any help - even if it is not consistent with this solution. I agree with being completely wrong. =)
You must add the part of the date as a static string in your code. Something like this:
util. SCAND ("h: mm tt d/m/yy", strStart + "01/01/15");
-
Normally, I'd use ArtDirector Toolkit, but I can not install it or software at the present time (too long to explain why) remove.
In any case, I have several items on the scale, and I'll try to find a formula/calculation to determine the scale.
Example - 1 item is 3,7486 "and I want that it 5,3231" - how to calculate the percentage of the scale to expand it?
I know you smart popular forum can help!
Thank you!
142.00234754308275%
Hugh Betcha wrote: normally I'd use ArtDirector Toolkit, but I can not install it or software at the present time (too long to explain why) remove.
Alternatively, you can Google "scale percentage between two numbers" - gives a lot of info free/calculators
-
Help: How do I calculate the duration between 2 dates, when these dates on 2 rows?
Hello
We are 11g.
We have a table with times recorded in a column. Then, each line as a different date value.
There is no pb to order the query on this date column (obviously)
Now, we need to calculate the period of time between 2 successive rows.
I first thought to use a cursor, the cursor loop, compute and update the "duration" column
It's the basic option
Now, I would like to know if, by using a single query, I couldn't directly the calculation I want?
Here is my example:
Ideally, that's what I would get (if my math is correct)WITH t AS ( SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual ) SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1 FROM t ORDER BY col1, date1;
I hope I'm clear!COL DATE1 DURATION --- ----------------- ---------- aaa 20100201 09:23:50 0 aaa 20100201 13:14:33 13843 aaa 20100207 13:14:33 518400 bbb 20100202 09:21:10 0 bbb 20100203 10:11:06 89396 bbb 20100203 15:13:55 18169 bbb 20100210 17:14:27 612032
Thanks a lot in advance for your help
OlivierOf course; It's easy with the use of the function analytic lag:
WITH t AS (SELECT 'aaa' col1, to_date( '20100201 09:23:50', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'aaa' col1, to_date( '20100201 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'aaa' col1, to_date( '20100207 13:14:33', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100202 09:21:10', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100203 08:11:06', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100203 15:13:55', 'YYYYMMDD HH24:MI:SS') date1 FROM dual UNION ALL SELECT 'bbb' col1, to_date( '20100210 10:14:27', 'YYYYMMDD HH24:MI:SS') date1 FROM dual), t_diff as (SELECT col1, to_char( date1,'YYYYMMDD HH24:MI:SS') date1, (date1 - lag(date1, 1, date1) over (partition by col1 order by date1))*24*60*60 date_diff FROM t) select col1, date1, sum(date_diff) over (partition by col1 order by date1) duration from t_diff ORDER BY col1, date1;
Published by: Boneist on February 15, 2010 16:39
(I can't read; initially gave the cumulative total of the period. Oh!)ETA2: Take note of the additional parameters, I used in the lag() - the third parameterd manages what should be the value in the field if there is no previous rank, so there is no need to use nvl elsewhere in the application to handle this situation.
Published by: Boneist on February 15, 2010 16:42
Maybe you are looking for
-
My screen has erased on my iPhone 5
Screen went blank on my iphone 5
-
Anatel logo at the back of the iphone 5 s
Hello everyone I just bought a new iphone 5 s in Dubai and discovered there anatel logo on the back of my iphone... I HAV never seen this logo before... Please help im so confused... should I go to the shop n return the iphone... When I bought the ip
-
I am wanting to do work under the hood of my new T410s works in "Safe Mode", but now the F8 key during reboot gives me an error message "Stuck Key", and then I headed directly into the BIOS/Start Up editing area. One advises on how to bypass this wei
-
Boolean flag indicating fileglobals
Hello! I m using this IOS in my projectsince there (almost) all we need: http://www.NI.com/example/31278/en/ However, I m a hard time to figure out how to add stuff on the interface. The only thing I need is four LED:s for four specific test step res