en Peris
en Peris

Reputation: 1717

Getting date time stamp difference minutes in Oracle Database 12c Enterprise Edition

I have this query to get the date time stamp difference minutes in Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production

SELECT TO_CHAR(GPS_FULL_DATE+2/24, 'MM-DD-YYYY HH24:MI:SS') GPS_DATE, 
       TO_CHAR(CREATION_DATE, 'MM-DD-YYYY HH24:MI:SS') CREATION_DATE,
       extract(minute from ((GPS_FULL_DATE+2/24)-CREATION_DATE)) mins
FROM server_data sd

But I got this error:

ORA-30076: invalid extract field for extract source
30076. 00000 -  "invalid extract field for extract source"
*Cause:    The extract source does not contain the specified extract field.
*Action:
Error at Line: 2 Column: 42

Upvotes: 1

Views: 61

Answers (1)

Littlefoot
Littlefoot

Reputation: 142720

(GPS_FULL_DATE + 2/24) - CREATION_DATE

returns number of days between two dates. Therefore, you can't extract number of minutes of it - you could, though, multiply the result by 24 * 60 (hours in a day * minutes in an hour) to get the desired value.

Upvotes: 2

Related Questions