Page 1 of 1

time difference

Posted: Wed Oct 21, 2009 4:27 am
by myasirm
hi guys
i have two columns in one table in both time is diffent i need the differnce of time and date between that and store in third column how can i do this i have used that format 21/10/2009 01:17 and i am using oracle as back end database

Re: time difference

Posted: Wed Oct 21, 2009 5:12 am
by Mark Baker
I can't understand the need to store the result in a new column it if you're already storing the two dates used for the calculation

But it's as simple as date1 - date2

If you have

Code: Select all

 
CREATE TABLE RCD_FILE_TREE
(
  FILE_ID              NUMBER                   NOT NULL,
  FILE_TYPE            VARCHAR2(16 BYTE)        NOT NULL,
  FILE_NAME            VARCHAR2(64 BYTE)        NOT NULL,
  FILE_PARENT_ID       NUMBER,
  CREATED_ON           DATE                     DEFAULT SYSDATE,
  LAST_UPDATED_ON      DATE
)
 
Then

Code: Select all

 
SELECT LAST_UPDATED_ON - CREATED_ON AS DAYS_INTERVAL
  FROM RCD_FILE_TREE
 WHERE FILE_ID = 1
 

Re: time difference

Posted: Thu Oct 22, 2009 1:41 am
by myasirm
thx dear i resolved my query with ur help