Skip to Main Content

Average between Dates

To my surprise, doing something like this is not possible in (PL)SQL:
This is a relatively elegant workaround:

Timestamp to Date

Don't use:
But use:
In "normal" queries the first method works, but it won't work correctly in views.

For "non-truncated" days, use:

Difference between Timestamps

Of course you can use something like this: But that gives you an interval, which I almost never need.

To get the (more convenient) difference between timestamps in seconds:
Result: 433928577.298375 seconds

Unix (Epoch) time

Unix (Epoch) time is the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970, minus leap seconds.

To calculate the number of milliseconds elapsed since then, taking your timezone into account, use this query:
Result: 1696232577303 milliseconds

Timezones

Conversion of a date from a timezone to the "database timezone":
and vice versa: