Convert time difference in seconds in hours, minutes, and seconds
Hi allI used the following logic to calculate the time difference between 2 passes of time for all the individual lines.
(floor ((TIME_ACTIONED-TIME_ALLOCATED) * 24) |) ':' || MOD (Floor ((TIME_ACTIONED-TIME_ALLOCATED) * 24 * 60), 60) |': ' | MOD (Floor ((TIME_ACTIONED-TIME_ALLOCATED) * 24 * 60 * 60), 60))
The user asked a column that displays the SUM of all the differences in time between the report.
Any help much appreciated!
Thank you
Sweta
Simply the sum of time_actioned - time_allocated, then do the same calculation you make on this sum.
John
Tags: Database
Similar Questions
-
How to set the clock for the hours, minutes, and seconds with Windows XP
How to set the clock for the hours, minutes, and seconds with Windows XP
I don't know of your question. If you ask how to show the clock in the tray system with hours, minutes and seconds, then download & run "Tclock Light". Windows will not natively display the seconds.
TClock Light: <> http://homepage1.nifty.com/kazubon/tclocklight/index.html >
HTH,
JW -
How to add days, hours, minutes and seconds to a date?
Hello
I have the following problem.
Saw 4 integers D, H, M, and S (each of them can be negative) and a date Da, I want to add days D, H hours, M minutes and seconds of S date Da.
For example, if
This means that I want to add 3 days, -2 hours, 20 minutes and -12 seconds to the date Da, and the new date must be in the following date:Da= to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss'), and D = 3, H = -2, M = 20 and S = -12,
Is it possible to write a query for this problem or should I use PL/SQL?to_date('01/07/2011 13:10:23','dd/mm/yyyy HH24:mi:ss')
Thank you.There is no need of PL/SQL
SQL> alter session set nls_date_format = 'DD/MM/YYYY HH24:MI:SS'; Session altered. SQL> var d number SQL> var h number SQL> var m number SQL> var s number SQL> exec :d := 3; :h := -2; :m := 20; :s := -12 PL/SQL procedure successfully completed. SQL> select to_date('28/06/2011 14:50:35','dd/mm/yyyy HH24:mi:ss') 2 + :d 3 + (:h / 24) 4 + (:m / 24 / 60) 5 + (:s / 24 / 60 / 60) 6 from dual; TO_DATE('28/06/2011 ------------------- 01/07/2011 13:10:23
-
Hello
I'm trying to calculate and history of lack of list based on the details of lack follows.
Here is what I got: (sorry for the dotted lines between the two, I put it just to format the data)
EMP_ID - WORK_DT - PM - REASON - PAID
=====-----=======------===-=====-- -- ====
123---06/01/2009---8.0---malades---PAYE
123---07/01/2009---8.0---malades---PAYE
123---08/01/2009---8.0---malades---PAYE
123---09/01/2009---8.0---malades---PAYE
123---16/01/2009---8.0---FMLA EMP - paid
123---17/02/2009---8.0---malades---PAYE
123---18/02/2009---8.0---malades---PAYE
123---30/03/2009---8.0---jure - paid
123---21/05/2009---4.0---malades---PAYE
123---22/05/2009---4.0---malades---PAYE
123---03/07/2009---8.0---malades---PAYE
123---25/08/2009---8.0---FMLA EMP - paid
123---26/08/2009---4.5---FMLA EMP - paid
123---21/09/2009---8.0---malades---non paid
123---22/09/2009---8.0---malades---non paid
I need to consolidate absences consecutive full day (8 hours) and show Start_dt, End_Dt, and also to calculate the duration of the absence in days, hours, min. If there is lack of half day (single or consecutive) is not followed by 8 hours, then they should be considered as a new incident (5/21 and 5/22). If the absence of half-day is followed by the absence of all day while they should be grouped together (8/25 and 8/26).
So for the data mentioned above the result should look like:
EMP_ID - START_DT - END_DT - DAYS - HOURS - minutes - INCIDENT - REASON - PAID
===---====== ---- ====== -- === - ==== - === - ====== - ====== -- -- =======
123 4 06/01/2009-01/09/2009 - 0---0---1 - disease - paid
123-16/01/2009 1-16/01/2009 - 0---0---2 - FMLA EMP - paid
123 2 17/02/2009-02/18/2009 - 0---0---3 - disease - paid
123 03/30/2009 1-30/03/2009 - 0---0---4 - Jury service - paid
123 21/05/2009 0 - 21/05/2009 - 4---0---5 - disease - paid
123 22/05/2009 0 - 22/05/2009 - 4---0---6 - disease - paid
123 03/07/2009 1-2009-03-07 - 0---0---7 - disease - paid
123-25/08/2009 1-08/26/2009 - 4-30-8 - EMP - paid FMLA
123 21/09/2009-22/09/2009-2-0-0-9 - disease - unpaid
I am able to group them to gether and get start_dt, end_dt and total days, hours as well as incident to help
Work_Dt - Row_Number() over (order of MIN (Work_Dt) and)
Row_Number() (order MIN (Work_Dt)
but it includes absences consecutive half-day (5/21 and 5/22) together as a single incident that should be considered as separate incidents. any idea or help in this case will be a great help.
Thank youStéphane wrote:
I'm trying to calculate and history of lack of list based on the details of lack follows.
As promised:
with t as ( select 123 EMP_ID,to_date('01/06/2009','mm/dd/yyyy') WORK_DT,8.0 HRS,'Sick' REASON,'Paid' PAID from dual union all select 123,to_date('01/07/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('01/08/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('01/09/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('01/16/2009','mm/dd/yyyy'),8.0,'FMLA EMP','Paid' from dual union all select 123,to_date('02/17/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('02/18/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('03/30/2009','mm/dd/yyyy'),8.0,'Jury Service','Paid' from dual union all select 123,to_date('05/21/2009','mm/dd/yyyy'),4.0,'Sick','Paid' from dual union all select 123,to_date('05/22/2009','mm/dd/yyyy'),4.0,'Sick','Paid' from dual union all select 123,to_date('07/03/2009','mm/dd/yyyy'),8.0,'Sick','Paid' from dual union all select 123,to_date('08/25/2009','mm/dd/yyyy'),8.0,'FMLA EMP','Paid' from dual union all select 123,to_date('08/26/2009','mm/dd/yyyy'),4.5,'FMLA EMP','Paid' from dual union all select 123,to_date('09/21/2009','mm/dd/yyyy'),8.0,'Sick','Unpaid' from dual union all select 123,to_date('09/22/2009','mm/dd/yyyy'),8.0,'Sick','Unpaid' from dual ) select EMP_ID, MIN(WORK_DT) START_DT, MAX(WORK_DT) END_DT, TRUNC(SUM(HRS) / 8) DAYS, TRUNC(MOD(SUM(HRS),8)) HOURS, MOD(SUM(HRS),1) * 60 MINs, INCIDENT, REASON, PAID from ( select EMP_ID, WORK_DT, HRS, REASON, PAID, sum(start_of_incident) over(partition by EMP_ID order by WORK_DT) INCIDENT from ( select t.*, case when lag(WORK_DT,1,WORK_DT) over(partition by EMP_ID order by WORK_DT) = WORK_DT - 1 and lag(HRS,1,8) over(partition by EMP_ID order by WORK_DT) = 8 and lag(REASON,1,REASON) over(partition by EMP_ID order by WORK_DT) = REASON and lag(PAID,1,PAID) over(partition by EMP_ID order by WORK_DT) = PAID then 0 else 1 end start_of_incident from t ) ) group by EMP_ID, INCIDENT, REASON, PAID order by EMP_ID, INCIDENT / EMP_ID START_DT END_DT DAYS HOURS MINS INCIDENT REASON PAID ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------------ ------ 123 01/06/2009 01/09/2009 4 0 0 1 Sick Paid 123 01/16/2009 01/16/2009 1 0 0 2 FMLA EMP Paid 123 02/17/2009 02/18/2009 2 0 0 3 Sick Paid 123 03/30/2009 03/30/2009 1 0 0 4 Jury Service Paid 123 05/21/2009 05/21/2009 0 4 0 5 Sick Paid 123 05/22/2009 05/22/2009 0 4 0 6 Sick Paid 123 07/03/2009 07/03/2009 1 0 0 7 Sick Paid 123 08/25/2009 08/26/2009 1 4 30 8 FMLA EMP Paid 123 09/21/2009 09/22/2009 2 0 0 9 Sick Unpaid 9 rows selected. SQL>
SY.
-
How to get the time in hours minutes and seconds subtraction between two varchar t
Hi all
I have two variable varchar that has a value like this
v_outpunch1: = 17: 50:00'
and v_Shifttime: = 18:00:00 '
This time I'm subtracting here and in another varchar variable
who's like that.
v_EarlyLeaverstimeformat: = ((extrait extrait de (heure de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-(heure de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss') LPAD)), 2, '0'): ': ' |)) LPAD ((extrait (minute de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (minute de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0'): ': ' |)) LPAD ((extrait (seconde de TO_TIMESTAMP (v_ShiftTime, 'HH24:mi:ss'))-extrait (seconde de TO_TIMESTAMP (v_OutPunch1, 'HH24:mi:ss'))), 2, '0');))
It is not properly subtracting value.
Thank youThis works for me...
SQL> ed Wrote file afiedt.buf 1 with t as(select to_date('17:50:00','HH24:MI:SS') as out, to_date('18:00:00','HH24:MI:SS') as shft from dual) 2 -- 3 select to_char(trunc(sysdate)+(shft-out),'HH24:MI:SS') as diff 4* from t SQL> / DIFF -------- 00:10:00
If you want something different, please report the details according to the FAQ: {message identifier: = 9360002}
-
Select the lists to the hours, Minutes and seconds
Apex 3.2
I need to create 3 selection lists.
One for the hour (24 hours)
One for the minutes
One for seconds
I couldn't just create selection lists in components that are shared using static values.
Is there a way to get the values using a select statement?
Gus
Hello
Try for example
SELECT 0 + LEVEL AS HH24 FROM DUAL CONNECT BY LEVEL <= 24
Kind regards
Jari
-
DateValidator and inputFormat, I would check hour minute and second too
Hi it is my will and I want to validate the whole date YYYYMMDD not only
< mx:DateValidator id = "dateVal" source = "{TI_FechaInicio}" = 'text' property, inputFormat = "yyyy-mm-dd L:NN:SS" / >
But it doesn't seem to work, so, how can I solve this?
The only thing about work are yyyy-mm-dd, but (L:NN:SS A) none of the above workYes, there's a RegExpValidator
http://livedocs.Adobe.com/flex/201/langref/MX/validators/RegExpValidator.htmlI hope that you do not validate the date by using a regular expression, I mean you'd need one hell of a regexp to validate the fact that exactly the number of days in a month, at a few minutes to an hour, etc.
I recommend you to read the doc "Creating and extending Flex components", it is a good example on how to make your own validator
-
Hour, minute and second is missing when you use Row.getAttribute)
Hello.
JDeveloper 11.1.1.2
If I do:
SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd hh: mm");
Line r = myRowSet.next)
Date myDate = r.getAttribute ("arrival") (Date);
System.out.println ("arrived:" + sdf.format (myDate));
the exit time is always printed as 12:00, even though the time may 09:31.
That is to say.
Arrival: 2011-12-24 12:00
Why?
Best regards
ErikCheck the data type of the attribute in the EO and VO. If they are java.sql.Date you must change to the java.sql.Timestamp or oracle.jbo.domain.Date, which holds at the time and the date.
Timo
-
A design of query for the conversion of time difference in days, hours, Minutes
Hi all
A design of query for the conversion of time difference of time in number of days remaining remaining hours minutes and rest in seconds. Made this one till now. Please suggest for all modifications, until now, it seems to work very well, kindly highlight for any anomaly.
WITH DATA (startDAte, EndDate, Datediff) AS (SELECT to_date ('2015-10-01 10:00:59 ',' yyyy-mm-dd hh24:mi:ss'), to_date ('2015-20-01 03:00:49 ',' yyyy-mm-dd hh24:mi:ss'), to_date('2015-10-01 10:00','yyyy-dd-mm hh24:mi:ss')-to_date('2015-20-01 03:00','yyyy-dd-mm hh24:mi:ss') FROM dual)
UNION ALL SELECT to_date ('2015-10-01 10:00:39 ',' yyyy-mm-dd hh24:mi:ss'), to_date ('2015-20-01 03:00:40 ',' yyyy-mm-dd hh24:mi:ss'), to_date('2015-10-01 10:00','yyyy-dd-mm hh24:mi:ss')-to_date('2015-20-01 03:00','yyyy-dd-mm hh24:mi:ss') FROM dual
UNION ALL SELECT to_date ('2015-11-01 10:30:45 ',' yyyy-mm-dd hh24:mi:ss'), to_date ('2015-11-01 11:00:50 ',' yyyy-mm-dd hh24:mi:ss'), to_date('2015-11-01 10:30','yyyy-dd-mm hh24:mi:ss')-to_date ('2015-11-01 11:00 ',' yyyy-mm-dd hh24:mi:ss') FROM dual
UNION ALL SELECT to_date ('2015-11-01 09:00:50 ',' yyyy-mm-dd hh24:mi:ss'), to_date ('2015-11-01 10:00:59 ',' yyyy-mm-dd hh24:mi:ss'), to_date('2015-11-01 09:00','yyyy-dd-mm hh24:mi:ss')-to_date ('2015-11-01 10:00 ',' yyyy-mm-dd hh24:mi:ss') FROM dual
UNION ALL SELECT to_date ('2015-11-01 08:30:49 ',' yyyy-mm-dd hh24:mi:ss'), to_date ('2015-11-01 09:30:59 ',' yyyy-mm-dd hh24:mi:ss'), to_date('2015-11-01 08:30','yyyy-dd-mm hh24:mi:ss')-to_date('2015-11-01 09:30','yyyy-dd-mm hh24:mi:ss') FROM dual
)
Select
trunc ((EndDate-StartDate)) days.
trunc (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24) hours)
trunc (to_number (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24-trunc (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24)) * 60) Minutes,))
(to_number (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24-trunc (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24)) * 60 - trunc (to_number (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24-trunc (((enddate-startdate)-to_number (trunc ((enddate-startdate))) * 24)) * 60)) * 60 seconds))))
data;
Thanks for the answers in advance.
AHA!
TO_TIMESTAMP expects a string as input, so it first makes an implicit conversion from DATE to a string, in the format of NSL_DATE_FORMAT.
To convert the TIMESTAMP DATE independently NLS_DATE_FORMAT, use
CAST (
AS TIMESTAMP) -
The cursor does not show hour minute second
Hello.
I have the following
PROCEDURE SP_GETHISTORICPAYMENT)
IO_CURSOR ON T_CURSOR,
O_CODTRANS OUT VARCHAR2,
IS
Tester varchar2 (2000);
BEGIN
Open the IO_CURSOR for
Select tlt_date in the BF_MTP_TRA_LOGTRANSACTIONAL where rownum < 2;
Select tlt_date in the BF_MTP_TRA_LOGTRANSACTIONAL Tester where rownum < 2;
O_CODTRANS: = Tester;
"The value of tlt_date is 13 May 15 15:27:32.
The result of the execution of the stored procedure is:
IO_CURSOR = 13 MAY 15 00:00:00 '
O_CODTRANS = 13 May 15 15:27:32 '
Why the cursor is not displayed the minute and the second time?
I tried with
Open the IO_CURSOR for
Select TO_DATE (tlt_date, ' dd/mm/YY hh24:mi:ss') of BF_MTP_TRA_LOGTRANSACTIONAL where rownum < 2;
But it does not work.
How can I do to get the hour minute and second of a cursor in a procedure.
Thank you.
Do you like reading and thinking about the answers? Last attempt:
PROCEDURE SP_GETHISTORICPAYMENT)
IO_CURSOR ON T_CURSOR)
IS
BEGIN
Open the IO_CURSOR for
Select TO_CHAR (tlt_date, ' dd/mm/YY hh24:mi:ss') of BF_MTP_TRA_LOGTRANSACTIONAL where rownum< 2="">
END SP_GETHISTORICPAYMENT;
SY.
-
How can I make the hour, Minute, second information in the RMAN log?
DB version: 11.2.0.3
Platform: Oracle Enterprise Linux 6.2
An excerpt from log RMAN backup file.
As indicated by the arrows below, the RMAN backup log only information hour, Minute, and second. It was just the date 14 October 13
archived journal entry thread = 1 sequence = RECID 10946 = STAMP 21079 = 828801629
archived journal thread = 2 sequence = 10137 entry RECID = STAMP 21081 = 828801794
archived journal thread = 1 sequence = 10947 entry RECID = STAMP 21080 = 828801731
CH01 channel: from song 1 to 14 October 13-> we need some time here as 17:28:43
channel ch00: finished piece 1 to 14 October 13
piece handle = al_9306_1_828819222 tag = comment TAG20131014T190816 = Version of the API 2.0, MMS Version 5.0.0.0
channel ch00: complete set of backups, time: 00:14:55
channel ch00: archived deletion or newspapers
.
.
< snipped >
How can I set up the equivalent of below declaration for registration of RMAN?
ALTER session set nls_date_format = 'YYYY-MM-DD HH24:MI:SS ";
Hello
We recommend that you always set you variable NLS_DATE_FORMAT so tah you see the hou, minute and second components of the date when the RMAN command. IF you be wrapped a gall newspaper during backup, restore and recovery controls, then this will ensure that a component of timestamp is disapled. This cabin can be useful when you are trying to solve the problems of RMAN.
If you do not set NLS_DATE_FORMAT, then you will not see the hour, minute, and the second component of the date columns. Excerpt from the output of a list without set NLS_DATE_FORMAT command:
Time of accomplishment of TIME TYPE LV SIZE DEVICE TYPE ELAPSET BS keys
---- --- ----- ------- ---- ---------------------------------------------
201 full DISCK 18.66 M 03:00:00 January 1, 13
Here is the result even when the NLS_DATE_FORMAT is set. Notice how the hours, the minutes and the seconds are now displayed:
Time of accomplishment of TIME TYPE LV SIZE DEVICE TYPE ELAPSET BS keys
---- --- ----- ------- ---- ---------------------------------------------------------------------------------
201 full DISCK 18.66 M 03:00:00 January 1, 13 12:11:25
You can check the value of NLS_DATE_FORMAT of your operating system with the echo command environment. ON UNIX, use echo as follows:
$echo $NLS_DATE_FORMAT
Here is an example of Windows to display NLS_DATE_FORMAT using the echo command:
c:\>echo % NLS_DATE_FORMAT %
To disable an OS variable, simply make it void. For example, to unset NLS_DATE_FORMAT in an environment of the UNIX C shell, use the OS unsetenv command:
$unsetenv NLS_DATE_FORMAT
IN an environment of the UNIX KORN shell, use export OS as follows:
$export = NLS_ADTE_FORMAT
-
TIME REMAINING IN SECONDS FROM THE END OF THE MONTH
Dear all,
How to calculate the time remaining is seconds to the end of the month?
time difference in seconds of sysdate to the last day of the month till 23:59:59
Thanks in advance
Hello
SELECT (ADD_MONTHS (TRUNC (SYSDATE, 'MONTH')
1
)
-SYSDATE
) * 24 * 60 * 60 AS seconds_left
DOUBLE;
SYSDATE is the date and time.
TRUNC (SYSDATE, 'MONTH') is the beginning of the current month
ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1) is the beginning of the next month
ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1)-SYSDATE is the number of days (not necessarily an integer) by the end of the month
(ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1)-SYSDATE) * 24 is the number of hours (not necessarily an integer) by the end of the month
...
-
Compliments of the season to you all. I am trying to create a timespan that ends in 'ago' at the end to show when an element of the webapp is out. For example:
If it's seconds, "there are 2 seconds'
If it's minute, "there are 1 min"
If there is time, "1 hour ago"
If day is "there are 1 day"
If there are months ' 2 months ago"
If this is year "1 year ago"
One with a liquid to share loans is appreciated. Thank you.
It is done in a hurry, a cleaner version is possible with a pretty picture initially but it is here:
{% assign myDate = "2016-01 - 01 T 00: 00:01Z '-%}
{% assign time = myDate: convert: 'day'-%} {% Comment %} This is just an example, to change to what you need to {% endcomment %}
{% assign lengths = '86400,3600,60,1-' %}
{% assign lengthsArr = lengths | divided: "," %}
{% attribute the difference = globals.site.dateNow | minus: time-%}
{% assign timeSpan = difference | date: ' JJ ': 'hh': 'mm':'ss '-%}
{"% assign timeSpanArr As timeSpan | divided: ' ': '-%}
{% assign total: 0 - percent}
{% assign count = - 1-%}
{% for article on timeSpanArr-%}
{% set count = count | more: 1 %-}}
{% assign len = lengthsArr [count]: convert: «number»-%}
{% assign seconds = item: convert: 'number': times: len-%}
{% assign total total = | most: seconds-%}
{% endfor}
{% If the total}< 60="">
{assign [interval = "second, 1" | divided: "," %]}
{% elsif total< 3600="">
{assign [interval = "minute, 60 ': divided:","%]}
{% elsif total< 86400="">
{assign [interval = 'hour', 3600 | divided: "," %]}
{% elsif total< 2628000="">
{assign [interval = "day 86400" | divided: "," %]}
{% elsif total< 31556926="">
{assign [interval = "month, 2628000 ': divided:","%]}
{%-%}
{assign [interval = 'year 31556926' | divided: "," %]}
{endif %}
{% yield duration = range [0]-%}
{% affect terms = interval [0] | append: "s"-%} {% Comment %} As append doesn't work in pluralize {% endcomment %}
{% assign termSeconds = interval [1]: convert: «number»-%}
{% assign total = total %}
{% assign termseconds = termseconds | number: 'F1'-%}
{% assign timeAgo total = | divided_by: termSeconds-%}
{{timeAgo | round}} {{timeAgo | round | pluralize: terms, term}} ago
Hope this can help, I would like to know if there are problems with it. Thank you.
EDIT:-weeks and rounded the timeago var.
-
Show the average time in days hours minutes seconds
Hello
I have two tables as follows,
Is it possible to separate the average time in days, hours, minutes, seconds.
I need the average time required for each account.
with
Table1 as
(select "AAA" acname, 123 tid, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') ltime Union double all the )
Select 'AAA', 456, to_date (January 11, 15 15:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 'BBB', 789, to_date (11 January 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 'CCC', 990, to_date (11 January 15 18:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 'BBB', 880, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 'DDD', 770, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 'BBB', 555, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
),
Table2 as
(select txid 123, to_date (January 11, 15 14:00 ',' dd-mm-aa hh24:mi:ss') mtime of union double all the )
Select 456, to_date (January 11, 15 16:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 789, to_date (11 February 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 770, to_date (11 February 15 07:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 990, to_date (11 January 15 23:30 ',' mm-dd-aa hh24:mi:ss') of all the double union
Select 880, to_date (11 February 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 555, to_date (11 February 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
)
Choose acname, avg (hrs)
from (select distinct t1.acname, (t2.mtime - t1.ltime) * 24 h )
from table1 t1,
Table2 t2
where t1.tid = t2.txid
)
Group acnameExpected results
ACNAME Avg (day) APR (hrs) Avg (Mins) Avg (dry)
AAA 0 1 0 0 (that is to say 14:00-13:00 = 1 and 16 15 = 1, Avg = (1 + 1) / 2 = 1)
BBB 1 0 0 0
CCC 0 5 30 0
DDD 1 2 0 0
with
Table1 as
(select 'AAA' acname, 123 tid, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') ltime Union double all the)
Select 'AAA', 456, to_date (January 11, 15 15:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 'BBB', 789, to_date (11 January 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select "CCC", 990, to_date (11 January 15 18:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 'BBB', 880, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 'DDD', 770, to_date (11 January 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 'BBB', 555, to_date (January 11, 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
),
Table2 as
(select txid 123, to_date (January 11, 15 14:00 ',' dd-mm-aa hh24:mi:ss') mtime of union double all the)
Select 456, to_date (January 11, 15 16:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 789, to_date (11 February 15 04:00 ',' dd-mm-aa hh24:mi:ss') of all the double union
Select 770, to_date (11 February 15 07:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 990, to_date (11 January 15 23:30 ',' mm-dd-aa hh24:mi:ss') of all the double union
Select 880, to_date (11 February 15 05:00 "," dd-mm-yy hh24:mi:ss') of all the double union
Select 555, to_date (11 February 15 13:00 ',' dd-mm-aa hh24:mi:ss') of double
)
Select acname,
trunc (AVG (Days)) days,
trunc (mod (AVG (Days), 1) * 24) hours,
trunc (mod (AVG (Days) * 24.1) * 60) minutes.
trunc (mod (AVG (Days) * 24 * 60.1) * 60) seconds
from (select distinct t1.acname,(t2.mtime-t1.ltime) days
FROM table1 t1,
table2 T2
where t1.tid = t2.txid
)
Acname group
/
ACN DAYS HOURS MINUTES SECONDS
--- ---------- ---------- ---------- ----------
BBB 31 0 0 0
CCC 0 5 30 0
AAA 0 1 0 0
DDD 31 1 0 0
SQL >
SY.
-
How to convert times from second to hh with CVI
How to convert times from second to hh with CVI?
Can anyone advice?
It's here. As I told you, it's very simple:
//---------------------------------------------------------------------- // Function secToHMSstring () //---------------------------------------------------------------------- /// HIFN secToHMSstring () /// HIFN The function takes an amount of seconds and returns a string with /// HIFN the corresponding value in H:M:S format /// HIPAR sec/Value in seconds to convert /// HIPAR verbose/If True use "hms" separators; if not, use ":" separator /// HIPAR string/The output string. It is responsibility of the programmer /// HIPAR string/that the string is large enough to keep the resulting text /// OUT string void secToHMSstring (int sec, int verbose, char *string) { int hh = 0, mm = 0, ss = 0; if (sec >= 3600) { hh = sec / 3600; sec -= hh * 3600; } if (sec >= 60) mm = sec / 60; ss = sec - mm * 60; strcpy (string, ""); if (verbose) { if (hh > 0) sprintf (string, "%s%dh", string, hh); if (mm > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%dm", string, mm); } if (ss > 0) { if (strlen (string)) strcat (string, " "); sprintf (string, "%s%ds", string, ss); } } else { if (hh > 0) sprintf (string, "%s%d:", string, hh); if (mm > 0) { if (strlen (string)) sprintf (string, "%s%02d:", string, mm); else sprintf (string, "%d:", mm); } else if (strlen (string)) strcat (string, "00:"); if (strlen (string)) sprintf (string, "%s%02d", string, ss); else sprintf (string, "%d", ss); } return; }
Maybe you are looking for
-
I'm getting messagage 'Thunderbird has stopped working ".
This message came whenever I opened it and tried to use Thunderbird today, it's driving me crazy. Also, it is not the first time that this has happened
-
Suspected false call from someone claiming to be a Microsoft technician.
I had what I think, it was a false call of a man who sounded Indian and who claims to be a Microsoft technician. He was adamant I had a very infected computer and was desperate to make me sit in front of my computer and type something so he could sho
-
my painting has disappeared from the computer
I went to pull up my "painting," and it has disappeared from my computer. I've looked everywhere... How can I get that back on?
-
Records MPEG4 and Media Center Extenders
Comcast told me hat they will use MPEG4 for HD channels. I use an InfintiTV tuner and checked with them to see if there are problems there. The response below indicates the only question of the reason could be to try to watch shows recorded on the
-
Smartphones from blackBerry 8350i direct connection settings
Is it possible to directly set the connection settings to vibrate all the time. I can set alerts to vibrate, but I can't figure out how to keep my private conversations. When the profile is set to vibrate all the direct connect notification and app