Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Finding the age of an event in Oracle

User_BP9OSSep 13 2022 — edited Sep 13 2022

I have a table of sales with an ordered column as a timestamp type. I would like to find the number of days since the last order. I though it should be simple.
I have tried various methods, but I can’t get a meaningful answer:

select max(ordered) from sales;                         --  2022-05-17 22:47:24.467000
select sysdate-max(ordered) from sales;                 --  Unknown column type: 10
select current_time_stamp-max(ordered) from sales;      --  Unknown column type: 10

I want to use the result in a CTE to then add to some other dates, so I thought it should at least result in either an interval type or a number of days.
How can I get the age of the above date?

Comments
Post Details
Added on Sep 13 2022
2 comments
209 views