0

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"

1 Answers1

2

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

Mikhail Berlyant
  • 165,386
  • 8
  • 154
  • 230
  • I believe this works fine for seconds less than 86400 (1 day). 86399 would be `23:59:59`, but 86400 is `00:00:00`. If you expect durations of 1 day or longer, maybe this solution works better: https://stackoverflow.com/a/64517385/1549523 – Ani Sep 09 '21 at 23:07