Reputation: 1
I am new to oracle.
I have some problems to make query.
Im trying to make query that solves the difference between sysdate() and the date from my own table
select to_char(to_char(sysdate,'YYYYMMDDHH24MISS')
- to_char(S_DATE||S_HOUR||':00' , 'YYYYMMDDHH24MISS'))
from dual;
I'm doing like that.
In my table, I have two columns 'S_DATE'
and 'S_HOUR'
that means time.
So, I would like to know the time difference and how to make this query. Thank you in advance.
Upvotes: 0
Views: 776
Reputation: 2715
You can get difference between two dates by simple - (minus) operator. However first you need to convert date string to date using TO_DATE
.
Sample in SQL Fidlle is here
The sample query:
select
sysdate , S_DATE || ' ' || S_HOUR "Date",
round((sysdate - to_date(s_date || s_hour ,' YYYY/MM/DDHH24:MI') ) * 24 * 60, 2) "Dif In Min",
round((sysdate - to_date(s_date || s_hour ,' YYYY/MM/DDHH24:MI') ) * 24 * 60 * 60, 2) "Dif In Sec"
from myDate
Upvotes: 2