问题
I need to parse
a datetime
contains milliseconds for matching the max value in a field containing this datetimes.
For example:
#standardSQL
SELECT PARSE_DATETIME('%Y-%m-%d %H:%M:%S.%u','2017-08-18 16:04:40.890')
Any suggestions? Thanks in advance.
UPDATE: Convert to milliseconds, suddendly MAX()
.
#standardSQL
WITH Input AS (
SELECT date
FROM UNNEST([
DATETIME '2017-08-18 16:04:40.890',
DATETIME '2017-07-27 11:09:10.347',
DATETIME '2017-08-22 13:17:34.727',
DATETIME '2017-08-22 13:17:34.737']) AS date
)
SELECT
MAX(CAST(date AS DATETIME))
FROM Input;
回答1:
below is for BigQuery Standard SQL
#standardSQL
SELECT PARSE_DATETIME('%Y-%m-%d %H:%M:%E*S','2017-08-18 16:04:40.890')
来源:https://stackoverflow.com/questions/46238787/milliseconds-format-to-parse-a-datetime