String to Date and Timestamp
In BigQuery you can use the following functions
Usage examples:
Date as input | Function Call |
2017/02/08 | TIMESTAMP(PARSE_DATE('%Y/%m/%d',date)) |
08/02/2017 | TIMESTAMP(PARSE_DATE('%d/%m/%Y',date)) |
08-02-2017 | TIMESTAMP(PARSE_DATE('%d-%m-%Y',date)) |
02082017 | TIMESTAMP(PARSE_DATE('%d%m%Y',date)) |
String to numeric
Number as input | Function call |
5 | CAST(number AS int64) |
2.3 | CAST(number AS float64) |
For BigQuery’s Legacy SQL you can alternatively use the function INTEGER(number)
and FLOAT(number)
.