Take the 2-minute tour ×
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's 100% free, no registration required.

Can't seem to figure this out. Just need the difference in minutes between 2 oracle timestamp columns.

END_TS                                  START_TS
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
11-NOV-13 PM                            11-NOV-13 PM
11-NOV-13 PM                            11-NOV-13 PM
18-NOV-13 PM                            18-NOV-13 PM
22-NOV-13 AM                            22-NOV-13 AM
share|improve this question

closed as off-topic by Mark Storey-Smith, Paul White, RolandoMySQLDBA, ypercube, Max Vernon Feb 26 '14 at 5:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – Mark Storey-Smith, Paul White, RolandoMySQLDBA, ypercube, Max Vernon
If this question can be reworded to fit the rules in the help center, please edit the question.

Why this post has been closed ? This question is quite general. I don't see where it is off-topic... –  Guillaume Nov 6 '14 at 14:07

2 Answers 2

Assuming your table is called TS:

SELECT EXTRACT (DAY FROM (end_ts-start_ts))*24*60*60+
EXTRACT (HOUR FROM (end_ts-start_ts))*60*60+
EXTRACT (MINUTE FROM (end_ts-start_ts))*60+
EXTRACT (SECOND FROM (end_ts-start_ts))

Common sense, to be honest.

(May need an EXTRACT(YEAR too).

share|improve this answer
    (cast(current_timestamp as date) - cast(<other_timestamp> as date))
    * 24 * 60
  ) as diff_minutes
from <some_table>;

This is what I used to calculate the difference between the current timestamp and a heart beat table entry for latency monitoring.

share|improve this answer
Why this one has been downvoted ? The query doesn't look too bad in my mind and is easier to read than the other answer... –  Guillaume Nov 6 '14 at 14:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.