0

在使用 DB Browser for SQLite 时,我如何转换例如:

2017-06-20T23:12:58Z

只是没有字符“T”和“Z”且没有时间的日期(2017-06-20)?

如果我使用CAST(expression as date)或者CAST(expression as datetime)我只得到年份(2017)而不是日期和月份。

4

1 回答 1

0

SQLite 没有日期类型。但是你可以做一些简单的字符串解析。

尝试这个:

SELECT d.orig_date, substr(d.orig_date, 1, INSTR(d.orig_date,'T') -1 ) as new_date_only
FROM 
    (SELECT '2017-06-20T23:12:58Z' as orig_date
    ) d
于 2020-04-27T19:24:04.473 回答