如何转换“1985-02-07T00:00:00.000Z"(ISO8601) 到 Oracle 中的日期值?

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"(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 中的日期值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL/MySQL: split a quantity value into multiple rows by date(SQL/MySQL:按日期将数量值拆分为多行)
SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to group by continuous records in SQL(如何在SQL中按连续记录分组)