Add two timestamp columns
I have 2 timestamp columns in a table
Columnname type
LoginTime Timestamp
LogoutTime TimeStamp
Need to find total hours... how to add 2 timestamp columns.. help me...
Abi,
As pointed out by Olaf, you are looking for the DATETIME type and not TIMESTAMP. The latter is just a rowversion value that helps to identify the version of each row inserted. The DATETIME type helps you to store YYYY-MM-DD HH:MM:SS.xxx format values as
required.
If your requirement is to find out the DIFFERENCE numebr of hours between the login and logout then the below query 1 shud help.
(Im not sure what you mean by TOTAL hours - ADDING the two timestamp values.. If your looking at the total number of hours passed from day zero, then query might as well help. Pls let us know if otherwise)
create table #temp
LoginTime datetime,
Logouttime datetime
insert #temp select getdate(),'2014-03-18 23:04:42.790'
insert #temp select getdate()-0.5,'2014-03-18 18:04:42.790'
insert #temp select getdate(),'2014-03-18 20:04:42.790'
--QUERY1:Finding the difference between the Login and logout times
select
Logintime,
Logouttime,
datediff(hour,LoginTime,Logouttime) as diff_hours
from #temp
--QUERY2:To find the SUM of hours of Login and logout
select
Logintime,
Logouttime,
datediff(hour,0,Logouttime) + datediff(hour,0,Logintime) as SUM_hours
from #temp
--cleanup
drop table #temp
Thanks,
Jay
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'>
Similar Messages
-
How to find the difference between two timestamp column
Dear All,
please Solve my issue,
I have Table name Record which has the following columns,
Empid in number column, dat in timestamp
which has the following values
Expand|Select|Wrap|Line Numbers
empid dat
====== ====
101 4/9/2012 9:48:54 AM
101 4/9/2012 9:36:28 AM
101 4/9/2012 6:16:28 PM
101 4/10/2012 9:33:48 AM
101 4/10/2012 12:36:28 PM
101 4/10/2012 8:36:12 PM
101 4/11/2012 9:36:28 AM
101 4/11/2012 4:36:22 PM
Here I need to display the following columns,
empid,min(dat) as start,max(dat) as end and difference(max(dat)-min(dat) for each day,
for eg,
Empid Strart end difference
101 4/9/2012 9:48:54 AM 4/9/2012 6:16:28 PM 8.28
like this.
Here 3 different days are exists so It should return 3 records with the above mentioned columns,
Please Help me to get this.
Thank you,
Regards,
Gurujothi
Edited by: Gurujothi on Apr 25, 2012 4:45 AM>
101 4/9/2012 9:48:54 AM 4/9/2012 6:16:28 PM 8.28
>
why 4/9/2012 9:48:54?
why not 4/9/2012 9:36:28 AM ?
SQL>
SQL> with t as
2 (select 101 empid, to_timestamp('4/9/2012 9:48:54 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
3 select 101, to_timestamp('4/9/2012 9:36:28 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
4 select 101, to_timestamp('4/9/2012 6:16:28 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
5 select 101, to_timestamp('4/10/2012 9:33:48 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
6 select 101, to_timestamp('4/10/2012 12:36:28 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
7 select 101, to_timestamp('4/10/2012 8:36:12 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual union all
8 select 101, to_timestamp('4/11/2012 9:36:28 AM', 'dd/mm/yyyy hh:mi:ss AM') dat from dual union all
9 select 101, to_timestamp('4/11/2012 4:36:22 PM', 'dd/mm/yyyy hh:mi:ss PM') dat from dual
10 )
11 select empid, min(dat) as start_dat
12 , max(dat) as end_dat
13 , max(dat)-min(dat) diff
14 from t
15 group by empid, trunc(dat)
16 /
EMPID START_DAT END_DAT DIFF
101 04.09.12 09:36:28,000000000 04.09.12 18:16:28,000000000 +000000000 08:40:00
101 04.11.12 09:36:28,000000000 04.11.12 16:36:22,000000000 +000000000 06:59:54
101 04.10.12 09:33:48,000000000 04.10.12 20:36:12,000000000 +000000000 11:02:24
SQL> -
How to add a new columns in table contorl in standard screen.
Hi All,
I am working on a enhancement for transaction VA01. I have to add few column for tab Additional Data B. In this tab column are displayed in table control. Now i have to add two more column in table control. Could you please help me to find out the exit and the way to populate the new columns.
Thanks
Piyush MathurHi Piyush,
That table control might have been created using an internal table i.e declared in the exit. Add two more fields which you want to that internal table. And come to the layout and create table control once again using that internal table.
Reward if helpful.
Regards,
Ramana -
HI Experts,
Can any one help me to add two more column for standard report that is purchase order and delivery dates for Internal order wise.
But here problem is when i checked with ABAP team they said there is no standard functional module to add two column.
Please note below :
Selection criteria is: 1) controlling area
2) Fiscal Year
3) From date and To date
4) Plan Version
5) Order Group.
My client suggested : S_ALR_87012993 this tcode to run, but we suggested with S_ALR_87013019 as in this tcode we can get all the details
That is required output fields, as it is showing all details but on yearly basis, he wants this to be period wise and also Abap team is not able to find standard functional module in the second tcode as well.
Out Put fields to Pop up
1) Orders.
2) Budget
3) Actual
4) commitment
5) Alloted
6) Available
These are two additional column
7)Purchase order
8) Delivery date.
Require your help to know which all tables are included to extract above out put fields please help me.
Thanks in Advance.
Regards,
SudeshHi Preeti,
Thanks for reply, can you please let me know is there any other way to show the output fields.
As my client is very specific to run the report on period wise, i also tried to execute the standard tcode S_ALR_87013019 and were we are getting all the required outputs to pop up but this is on year wise, but we can also check by period basis by clicking on order number and actual period basis where we can see period basis.
Also one more question,what is the commitment table which is popping up in this, please advise.
Thanks in advance.
Regards,
Sudesh -
Avg Time Difference of Two timestamps in Oracle SQL
Hello Members,
I am trying to find the average of Time Difference of two timestamp columns by order number. I need to show the average of the time difference in hours:mins format. I have is SQL Server , but unable to get this in Oracle SQL. Could anyone please let me know how I need to find the time difference of two timestamp columns and show them in hh:mm fomat and then take average of these differences and show them in hh:mm format. Below is what I have tried in SQL server.
CREATE TABLE temp
startdate smalldatetime,
enddate smalldatetime
INSERT temp
SELECT '6/22/2013 19:00',
'6/22/2013 19:20'
UNION ALL
SELECT '6/22/2013 19:22',
'6/22/2013 19:44'
UNION ALL
SELECT '6/22/2013 19:45',
'6/22/2013 19:50'
UNION ALL
SELECT '6/22/2013 19:52',
'6/22/2013 20:02'
UNION ALL
SELECT '6/22/2013 20:05',
'6/22/2013 20:10'
UNION ALL
SELECT '6/22/2013 20:15',
'6/22/2013 20:20'
SELECT CAST
CAST
( SUM
DATEDIFF(MINUTE,startdate,enddate)
6*60
As float)
as varchar) + ':' +
cast
cast
cast
SUM
DATEDIFF(MINUTE,startdate,enddate)
6
as int )
% 60 as float )
as varchar ) AS avg_time_diff_in_hh_mm_format
FROM temp
Please let me know if you need additional information.
Thanks in Advance.Thanks for the reply Frank,
I have tried some similar lines with your suggested approach, please see below:
--DDL
CREATE TABLE XX_ORD_TIMES
(ORDER_NUM NUMBER(15),
ACTUAL_START_DATE DATETIME,
ACTUAL_FINISH_DATE DATETIME)
--Sample Data
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SFM-07', TO_DATE('06/20/2013 14:22:58', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('06/21/2013 07:58:55', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SFM-07', TO_DATE('06/21/2013 09:12:42', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('06/21/2013 09:18:15', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SFM-07', TO_DATE('06/20/2013 15:59:07', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('06/20/2013 17:06:17', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SVCEXT', TO_DATE('05/16/2013 11:56:05', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/24/2013 14:47:54', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SVCEXT', TO_DATE('05/07/2013 09:23:37', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/07/2013 13:00:14', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SVCEXT', TO_DATE('05/09/2013 14:06:08', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/22/2013 13:25:03', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SVCNEWPLON', TO_DATE('05/21/2013 13:17:45', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/24/2013 14:35:04', 'MM/DD/YYYY HH24:MI:SS'));
Insert into XX_ORD_TIMES
(ORDER_NUM, ACTUAL_START_DATE, ACTUAL_FINISH_DATE)
Values
('SVCNEWPLON', TO_DATE('05/24/2013 09:00:04', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/29/2013 09:30:32', 'MM/DD/YYYY HH24:MI:SS'));
--Avg time diffs
SELECT ORDER_NUM,
ACTUAL_START_DATE
ACTUAL_FINISH_DATE
TO_NUMBER (
SUBSTR (
NUMTODSINTERVAL (
AVG (
CAST (ACTUAL_FINISH_DATE AS DATE)
- CAST (ACTUAL_START_DATE AS DATE)),
'DAY'),
2,
9))
* 24
+ TO_NUMBER (
SUBSTR (
NUMTODSINTERVAL (
AVG (
CAST (ACTUAL_FINISH_DATE AS DATE)
- CAST (ACTUAL_START_DATE AS DATE)),
'DAY'),
12,
2))
|| ':'
|| CASE
WHEN LENGTH (
TO_NUMBER (
SUBSTR (
NUMTODSINTERVAL (
AVG (
CAST (ACTUAL_FINISH_DATE AS DATE)
- CAST (ACTUAL_START_DATE AS DATE)),
'DAY'),
15,
2))) < 2
THEN
'0'
|| TO_NUMBER (
SUBSTR (
NUMTODSINTERVAL (
AVG (
CAST (ACTUAL_FINISH_DATE AS DATE)
- CAST (ACTUAL_START_DATE AS DATE)),
'DAY'),
15,
2))
ELSE
TO_CHAR (
SUBSTR (
NUMTODSINTERVAL (
AVG (
CAST (ACTUAL_FINISH_DATE AS DATE)
- CAST (ACTUAL_START_DATE AS DATE)),
'DAY'),
15,
2))
END
AS TIME_DIFF
FROM XX_ORD_TIMES
GROUP BY ORDER_NUM,
ACTUAL_START_DATE
ACTUAL_FINISH_DATE
order by 1;
Yes, I am trying to show the time difference of two timestamps ( finish date , start date ) in Hours:Mins and also calculate the average of this Hours : Mins by ORDER_NUM .
Please advise.
Thanks again. -
Add two attachment field in custom list through sharepoint designer 2013
Hi all,
I want to add two attachment columns to the SharePoint 2013 custom list through SharePoint Designer 2013 (not using ribbon attachment option) only . I managed to attach single attachment column to the attachment field. But I am not able to create second
field for attachment.
for example, one column for attaching address proof and second column for identity proof.
Any help would be appreciated.Out of the box this simply isn't going to be possible the way you seem to want it. The attachment field does allow for multiple attachment, but I can see why you'd potentially want these separated out.
Alternative:
You could instead create a link field for each. Users load the documents into a document library and then copy the URL to paste into the form. If you potentially need multiple attachments for each, you can use an InfoPath form and a repeating table.
Andy Wessendorf SharePoint Developer II | Rackspace [email protected] -
Add Two Column in report ,Download and Delete
Hi Friends,
i have one item File Browser to use browse :P1_file_browser and i have create a Report
My Table Is
CREATE TABLE "ARM_DOC_CER"
( "ID" NUMBER,
"NAME" VARCHAR2(500),
"MIME_TYPE" CLOB,
"BLOB_CONTENT" BLOB,
"SUBJECT" VARCHAR2(500)
i jus want to add two column in my report
1--Download
2--Delete
When i click on download then download file and when i click on delete then delete corresponding file.
How can i do this.
ThanksHi,
You can use concat function or also '||' to combine two columns.
1. with concat-
concat("D4 Product"."P01 Product","D4 Product"."P02 Product Type")
2. With '||' operator
"D4 Product"."P01 Product" || '-'||"D4 Product"."P02 Product Type"
(Remove '-' if not required)
This should resolve. Hope this helps
Regards
MuRam -
How to add two columns in criteria(OBIEE 11g)
Hi,
I am trying to add two columns in a criteria in obiee
*"Fact - OLB Processed Invoices"."Invoice Amount - Functional Currency"__"Fact - OLB Processed Invoices"."AR Tax Amount - Invoice Currency"
but the problem is :-
The first column have 500000000 and the second column contains NULL values the actual table. I think this might be the problem when I am trying to add them it is giving no output.
just a blank box.
Can any one tell me how can we add columns in this condition.
Thank to one and all.Try IFNULL(expr, value)
for other column
"Fact - OLB Processed Invoices"."Invoice Amount - Functional Currency"+IFNULL("Fact - OLB Processed Invoices"."AR Tax Amount - Invoice Currency",0)
Edited by: Srini VEERAVALLI on Mar 20, 2013 10:02 AM -
How to add two columns in OBIEE report?
Hi to All,
Can anyone tell me how to add two columns in OBIEE report and get that result in a new column?
Thanks in Advance,
ThenmozhiAssume you already have two columns SalesAmt1 and SalesAmt2, and you want to derive 3rd column say SalesAmt3 which would be the sum of SalesAmt1 and SalesAmt2.
For this, as I mentioned above pull SalesAmt1 and SalesAmt2 columns in Report. Now pull another column (say SalesAmt1) and open the fx. Clear the contents of fx. Now locate the columns button in the bottom of the fx. From Here, first select SalesAmt1 and + sign and the select SalesAmt2.
Now in this new column, the fx should look like SalesAmt1 + SalesAmt2.
Let me know if you are looking for something else.
Thanks -
How to add a column that shows the difference of two metrics columns?
I created a pivot table with two metrics columns. One metrics column has the aggregation rule of 'Min', the other has 'Max'. Now I want to add a column to show the difference of these two metrics for each row. Is this possible? How to do it? Thank you in advance.
Use TimeStampdiff:
TIMESTAMPDIFF(SQL_TSI_HOUR, MIN(xxxx), MAX(xxx))
It's in the help file if you need more help.
regards
Alex -
How to add a new column in between two other columns
I need to add a new column in between two other existing columns. Does anyone know how to do that? The ALTER statement adds the column at the end. Can someone give an example.
Thanks
Murali
nullThere is no simpler way of doing this because it is not strictly necessary: you can always see your data in the order you want simply by going SELECT col1, col2, col98, col4, etc. Thus the column order only matters when you execute SELECT * FROM...
If that really is important enough to you you'll have to drop and re-create the table, for which there are a number of different strategies.
Your final comment suggests that you don't retain your database build scripts. If you did then rebuilding your constraints would be painless. There is a lesson there. The good news is that if you have TOAD (download from www.quest.com) you can generate DDL scripts from your existing schema.
HTH, APC -
How to add two X Axis in the Column chart?Need Help
Hi,
I have a requirement to add two X axis in the SSRS column chart.Can someone please help how to add two X axis. I tried the secondary axis for horizontal axis but current x axis is shifting to other side, second X axis is not coming.
Regards
JonHi Jon,
According to your description, you want to add secondary X axis for one series in a column chart, right?
The secondary axis is useful when comparing two value sets with two distinct data ranges that share a common category. In Reporting Services, it’s not supported to create two X axis for one series. We can create secondary X axis when there are two series
in a column chart. As we tested in our local environment, we can add secondary X axis for specific series. Please refer to the screenshots below:
So I would like to know what’s your exact needs about creating two X axis for one series. If possible please share some detail information about your data and expected looking of the chart.
Reference: Plot Data on a Secondary Axis (Report Builder and SSRS)
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu -
How to add Two Columns in SQL
For Example
Jan Feb
215 NULL
How to add these two values in SQLAnything + NULL is NULL.
Check this:
SQL> SELECT 1 + NULL from dual;
1+NULL
SQL> You have to do this:
SQL> with t as (SELECT 235 JAN, NULL FEB FROM dual)
2 SELECT NVL(JAN,0) + NVL(FEB,0) FROM t;
NVL(JAN,0)+NVL(FEB,0)
235
SQL> -
Add Minutes to a Timestamp column
Hello there,
I need to know how to add minutes to a timestamp column in APEX. I was looking for an answer on the internet but the DATEADD function doesn't work in APEX. Any ideas?
RubenDATEADD is a SQL Server function.
I think using [interval data types|http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/sql_elements001.htm#i78291] and the NUMTODSINTERVAL function produces the clearest code:
with ts_example as (
select ename, cast(hiredate as timestamp) hirets from emp)
select
ename
, hirets
, hirets + interval '90' minute as intlit
, hirets + numtodsinterval(90, 'minute') as numtodsint
from
ts_example
ENAME HIRETS INTLIT NUMTODSINT
SMITH 17-DEC-1980 00.00.00.00 17-DEC-1980 01.30.00.00 17-DEC-1980 01.30.00.00
ALLEN 20-FEB-1981 00.00.00.00 20-FEB-1981 01.30.00.00 20-FEB-1981 01.30.00.00
WARD 22-FEB-1981 00.00.00.00 22-FEB-1981 01.30.00.00 22-FEB-1981 01.30.00.00
JONES 02-APR-1981 00.00.00.00 02-APR-1981 01.30.00.00 02-APR-1981 01.30.00.00
MARTIN 28-SEP-1981 00.00.00.00 28-SEP-1981 01.30.00.00 28-SEP-1981 01.30.00.00
BLAKE 01-MAY-1981 00.00.00.00 01-MAY-1981 01.30.00.00 01-MAY-1981 01.30.00.00
CLARK 09-JUN-1981 00.00.00.00 09-JUN-1981 01.30.00.00 09-JUN-1981 01.30.00.00
SCOTT 19-APR-1987 00.00.00.00 19-APR-1987 01.30.00.00 19-APR-1987 01.30.00.00
KING 17-NOV-1981 00.00.00.00 17-NOV-1981 01.30.00.00 17-NOV-1981 01.30.00.00
TURNER 08-SEP-1981 00.00.00.00 08-SEP-1981 01.30.00.00 08-SEP-1981 01.30.00.00
ADAMS 23-MAY-1987 00.00.00.00 23-MAY-1987 01.30.00.00 23-MAY-1987 01.30.00.00
JAMES 03-DEC-1981 00.00.00.00 03-DEC-1981 01.30.00.00 03-DEC-1981 01.30.00.00
FORD 03-DEC-1981 00.00.00.00 03-DEC-1981 01.30.00.00 03-DEC-1981 01.30.00.00
MILLER 23-JAN-1982 00.00.00.00 23-JAN-1982 01.30.00.00 23-JAN-1982 01.30.00.00
14 rows selected -
To Add Two ZFields to sales order Item (Column) of VA01
Hi friends,
My requirement is to Add Two Zfields at column level of Sales order Item of VA01.
i found 8459 Screen Exit , but it will display in Additional Tab B .
And aslo I need to get the zfield values for every line item .
Example:
ITEM | MATERIAL | SERVICIABLE MATERIAL | Service type(zfield)|
10 |10000 | 10001 | Cleaning
15 |20000 |200001 | Repair
i hope u understand my query . so for each line item it will vary , i have to do the validation for all the line item fields.
Please help me Very urgent.
Thanks,
Veera...Transaction Code - VA01 Create Sales Order
Exit Name Description
SDTRM001 Reschedule schedule lines without a new ATP check
V45A0001 Determine alternative materials for product selection
V45A0002 Predefine sold-to party in sales document
V45A0003 Collector for customer function modulpool MV45A
V45A0004 Copy packing proposal
V45E0001 Update the purchase order from the sales order
V45E0002 Data transfer in procurement elements (PRreq., assembly)
V45L0001 SD component supplier processing (customer enhancements)
V45P0001 SD customer function for cross-company code sales
V45S0001 Update sales document from configuration
V45S0003 MRP-relevance for incomplete configuration
V45S0004 Effectivity type in sales order
V45W0001 SD Service Management: Forward Contract Data to Item
V46H0001 SD Customer functions for resource-related billing
V60F0001 SD Billing plan (customer enhancement) diff. to billing plan
Rewards if useful.
Minal
Maybe you are looking for
-
Unable to set root/main/default servlet in Tomcat 5.5
I'm on a shared hosting account with Tomcat 5.5 and cannot figure out why I can't set the default servlet. I want all incoming requests regardless of the relative path, to be handled by the Redirect servlet. There is only one servlet in the whole pro
-
Availability of stdnormal_inv PL/SQL function in Oracle Database
I am in need of stdnormal_inv statistical function to calculate the Quantile of Standard Normal Distribution for safety stock computation in MRP module. If anyone knows whether any pl/sql code exists to compute stdnormal_inv, please help me with the
-
Search itens with item level security enabled
Hi, I have a page that "item level security" enabled. I am doing a select to get itens... How can I get only itens that current user have view permission? select wv.title, wvt.numbervalue, wv.description, '/pls/portal/url/ITEM/'||wv.guid link from po
-
Trnasfered plant from Ecc to APO, but location not found
Transfered plant from Ecc to APO, but the location is not available in APO Master data
-
Question on Blu ray image size output and reducing the size
Hi I have been using encore for blu ray projects which is been proving very helpful. However recently i have had a issue with output size on files. Normally Encore gives me it's estimate that it will fill the disc nicely and provides a image/folder w