[英]Convert a date and time string in the format YYYY-MM-DD HH:MM:SS in SQL
Is there any way to convert "A date and time string in the format YYYY-MM-DD HH:MM:SS” using legacy SQL syntax or standard SQL syntax in BigQuery. 有什么方法可以使用BigQuery中的旧版SQL语法或标准SQL语法转换“格式为YYYY-MM-DD HH:MM:SS的日期和时间字符串”。
For eg. 例如。 "November 9, 2017" to 2017-11-09 00:00:00
“ 2017年11月9日”至2017-11-09 00:00:00
Below is for BigQuery Standard SQL 以下是BigQuery标准SQL
#standardSQL
SELECT PARSE_DATE('%B %d, %Y', 'November 9, 2017')
result is 结果是
f0_
2017-11-09
or you can use 或者你可以使用
#standardSQL
SELECT PARSE_DATETIME('%B %d, %Y', 'November 9, 2017')
which returns 哪个返回
f0_
2017-11-09T00:00:00
SQL Server (2005, 2000, 7.0) does not have any flexible, or even non-flexible, way of taking an arbitrarily structured datetime in string format and converting it to the datetime data type. SQL Server(2005、2000、7.0)没有任何灵活的甚至不灵活的方式来获取字符串格式的任意结构化datetime并将其转换为datetime数据类型。
By "arbitrarily", I mean "a form that the person who wrote it, though perhaps not you or I or someone on the other side of the planet, would consider to be intuitive and completely obvious." “任意”是指“一种形式,尽管也许不是您或我或地球另一端的人,但是撰写它的人会认为它是直观且完全显而易见的。” Frankly, I'm not sure there is any such algorithm.
坦白说,我不确定是否有这样的算法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.