The question is how to convert a date to an epoch timestamp.
Here is a simple approach, that is consistent with your current code that turns the epoch to a date:
(mydate - date '1970-01-01') * 60 * 60 * 24
mydate represents the
date value that you want to convert.
Note that this uses the standard
date 'YYYY-MM-DD' to declare date literals, rather than using
to_date(). Using this syntax, your original code would be simpler expressed as:
date '1970-01-01' + mynumber / 60 / 60 / 24
CLICK HERE to find out more related problems solutions.