Return Oracle Timestamp

Asked

Viewed 793 times

1

I want to convert a date to a number, a timestamp. Within a select I need to return beyond the date her timestamp.

Example of consultation:

Select sysdate, TIMESTAMP_DE_SYSDATE from dual

Timestamp

is a time tag (or time stamp) that is a string denoting the time or date that a certain event occurred. The string is usually presented in a consistent format, allowing easy comparison between two distinct time marks. In Unix there is an important time tag defining the beginning of the Unix Age, "1970-01-01 00:00:00 UTC", used as a reference in the time calculation of that platform.

  • see if this answers: https://stackoverflow.com/questions/22245250/oracle-casting-date-to-timestamp-with-time-zone-with-offset

  • Worse than not, I need the return to be an integer, like this oh: https://www.unixtimestamp.com/

  • gambiarra, but it seems to work :P (in case you would convert the date into timestamp before) https://stackoverflow.com/a/26650393/4551469

  • 1

    kkkk this worked, I think maybe the solution is this same, I did not find anything better. I wanted something that sounded less verbose and more intuitive, but I don’t think it has :),

1 answer

2


Unfortunately there is no native Oracle function to get Unix datetime from a date.

The solution would be to do the calculation yourself, from the date of Unix epoch (01/01/1970). Follow example:

SELECT sysdate, ((sysdate - TO_DATE('1970-01-01', 'YYYY-MM-DD')) * 60 * 60 * 24) FROM dual
  • Thanks, sad to know you only have out of Ambi.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.