简体   繁体   中英

Invalid Time String Error when trying to change type of data from string to time

I am very new to data analytics and I need some help troubleshooting a SQL error I got. So, I have a column in this table which transferred over from Excel to SQL as a string type rather than a time piece of data. I want to make it into a time type so i can further analyze it.

So, I did the attached query to try and change the type of data using the CAST function. Image from BigQuery . However, it could not complete the query thanks to an outlier in the data set I have yet to clean the data and this was one of my first steps to so, but how do I remove this particular row that contains the invalid time string so the query can actually work? Or is there a better way to convert this entire column from text string to time?

BigQuery Time types adjust values outside the 24 hour boundary - 00:00:00 to 24:00:00 ; for example, if you subtract an hour from 00:30:00 , the returned value is 23:30:00 .

Based on your screenshot it looks like you are storing a duration? So 330 hours, 25 minutes and 55 seconds?

You would probably be best using timestamp, converting the hours to days and adding the remainder to your minutes and seconds.

You can then cast the resulting string to timestamp.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM