How to convert quot;1985-02-07T00:00:00.000Zquot; (ISO8601) to a date value in Oracle?(如何转换“1985-02-07T00:00:00.000Z(ISO8601) 到 Oracle 中的日期值?)
问题描述
我尝试将时间戳 ("1985-02-07T00:00:00.000Z") 转换为日期,但我多次尝试均未成功.
I tried to convert a time-stamp ("1985-02-07T00:00:00.000Z") to a date and I failed to succeed in my several different attempts.
以下是我尝试过的查询:
Below is the query I have tried:
select to_date('1985-02-07T00:00:00.000Z', 'YYYY-MM-DDTHH24:MI:SS.fffZ')
from dual;
非常感谢您的建议.
推荐答案
to_date 将输入转换为不支持小数秒的 DATE 类型.要使用小数秒,您需要使用在使用 to_timestamp
to_date converts the input to a DATE type which does not support fractional seconds. To use fractional seconds you need to use a TIMESTAMP type which is created when using to_timestamp
pst 关于 ff3 修饰符的评论也是正确的.
pst's comment about the ff3 modifier is also correct.
格式掩码中的常量"值需要用双引号括起来
"Constant" values in the format mask need to be enclosed in double quote
所以最后的陈述是:
select to_timestamp('1985-02-07T00:00:00.000Z', 'YYYY-MM-DD"T"HH24:MI:SS.ff3"Z"')
from dual;
这篇关于如何转换“1985-02-07T00:00:00.000Z"(ISO8601) 到 Oracle 中的日期值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何转换“1985-02-07T00:00:00.000Z"(ISO8601) 到 Oracle 中的日期值?
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 更改自动增量起始编号? 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
