-2

Experts,

I have this column I used the following to calculate the time difference between two time stamps:

x.created@::timestamp at time zone 'America/Los_Angeles' - usr.reviewed@t::timestamp at time zone 'America/Los_Angeles' AS T_time

I got a column like this:

Date                       | T_time
January 1, 2022, 12:00 AM  |  0 years 0 mons -51 days -24 hours -21 mins -21.264792 secs

I want this whole T_time in minutes so 51 days (minutes) + 24 (minutes) + 21 etc I tried using extract but that kind of just extracts minutes without adding.

Using Postgres on Metabase!

NasahT
  • 25
  • 1
  • 8

1 Answers1

0

Brute force method ->

extract(hour from CHK_OUT_TIME)*60::decimal as hrs,
extract(minute from CHK_OUT_TIME)::decimal as mins,
extract(second from CHK_OUT_TIME)/60::decimal as sec,
CHK_OUT_TIME as c
--AVG(CHK_OUT_TIME)
FROM b_data

SELECT time, AVG((days+hrs+mins+sec))/60 as AverageTime ,count(period) as CounnT from b_data2 group by 1

NasahT
  • 25
  • 1
  • 8