I have 2 varchars like:
How can I subtract to see if there is more than 24 hours of difference between the 2 values?
I tried using the symbol
- but it gives me an error. What is the best way?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
Here is the sample query to convert the given varchar2 value to date and calculated the difference in hour.
select (to_date('20160316124052', 'yyyy-mm-dd hh24:mi:ss')-to_date('20160316080002', 'yyyy-mm-dd hh24:mi:ss'))*24 DateAndTime from dual;
SELECT (sysdate-to_date(START_TIME,'YYYYMMDDHH24MISS'))*24 FROM LOGGING WHERE NAME='TERR_PAST' AND UPPER(STATUS) = 'EXECUTED';