Time difference between two columns storing only time in SQL

I have two columns (session_starttime & session_endtime) whose data type is a text. As seen in the image, it is only the time part that is stored and no date.

I have two columns (session_starttime & session_endtime) whose data type is a text. As seen in the image, it is only the time part that is stored and no date.

I am struggling to get a session duration in seconds. The ultimate goal is to get the average time per session.

I have tried the code below but it did not work

select 
avg(datediff('second', session_endtime,session_starttime)) as Average_settlement_time
from user_sessions ```

ERROR

(psycopg2.errors.UndefinedFunction) function datediff(unknown, text, text) does not exist LINE 8: avg(datediff(‘second’, session_endtime,session_starttime)) a…

HINT: No function matches the given name and argument types. You might need to add explicit type casts.

About the Author