I have two timestamp fields in my DB, which are th...
# announcements
r
I have two timestamp fields in my DB, which are the start time and end time of an operation. The value I am interested in is its difference, in seconds. How can I expose it as a column in my Query?
y
https://www.postgresql.org/docs/9.1/functions-datetime.html And more examples here: http://www.sqlines.com/postgresql/how-to/datediff Another way is what we are doing in our transforms for calculating Time to Close an issue for Gitlab data: https://gitlab.com/meltano/dbt-tap-gitlab/blob/master/models/base/gitlab_issues.sql
Copy code
...
round(abs(extract(epoch from closed_at - created_at))::numeric, 0) as time_to_close,
...
Pick what's better for you 😉
r
Thanks! Let me take a look!