0

I have 2 tables: Employees with the employee info and Download with the timestamp that the application was downloaded.

I have to subtract the current timestamp from the most recent download time stamp. I figured out the most recent download and also know how to get the current timestamp. I just can't figure out how to get the difference.

The query I used for getting the most recent download is:

SELECT MAX(srvr_timestamp) from jaherna42.download; --***dB.table

The query I used for getting the current timestamp is:

SELECT current_timestamp from dual;
Dai
  • 141,631
  • 28
  • 261
  • 374
AmberH
  • 3
  • 5
  • To subtract one timestamp or date from another you need to use... Subtraction. See [Datetime/Interval Arithmetic](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Data-Types.html#GUID-E405BBC7-DA9A-4DF2-9F22-E60CB9EC0705) – astentx Sep 30 '22 at 20:36
  • 1
    Does this answer your question? [Calculating difference between two timestamps in Oracle in milliseconds](https://stackoverflow.com/questions/11617962/calculating-difference-between-two-timestamps-in-oracle-in-milliseconds) – astentx Sep 30 '22 at 20:38

1 Answers1

0

Just subtract one from the other in the same query:

SELECT MAX(srvr_timestamp) - current_timestamp AS diff
from   jaherna42.download;

fiddle

MT0
  • 143,790
  • 11
  • 59
  • 117
  • Thank you it worked. I had it backwards because I thought you would have to subtract the max(srvr_timestamp) from the current_timestamp, since current time is "bigger" than the other times. – AmberH Sep 30 '22 at 18:24