Mohamad Elnass
Mohamad Elnass

Reputation: 3

BigQuery Convert number of seconds into time format

I'm trying to convert average total of seconds into time format PARSE_TIME( '%T', CAST(ROUND( IEEE_DIVIDE(SUM( totals.timeOnSite ), SUM(totals.visits)),0) AS STRING )) AS AvgSessionDuration,

code is valid, but it's giving me this error: Failed to parse input string "245"

Upvotes: 0

Views: 9146

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 172993

try below approach

time(timestamp_seconds(number_of_seconds_int64)) AS AvgSessionDuration    

instead of PARSE_TIME( '%T', CAST(ROUND( IEEE_DIVIDE(SUM( totals.timeOnSite ), SUM(totals.visits)),0) AS STRING )) AS AvgSessionDuration

Upvotes: 2

Related Questions