问题描述
--This works fine.
Select To_Date('11, Mar-2021', 'DD, Mon-YYYY')
From Dual;
--While this doesn't work even if I provided the correct
--format string too. In this I just used "th".
Select To_Date('11th, Mar-2021', 'DDth, Mon-YYYY')
From Dual;我可以知道为什么是第二个查询引发错误,而甲骨文说,to_date函数可以转换文字日期字符串,如果一个人提供了正确的格式模型,我做了完全相同的,最重要的是我甚至没有使用 “fx”。
谢谢。
专家解答
从文档中:
Datetime suffixes are valid only to format output
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Format-Models.html#GUID-515DFB76-E853-432F-BFEC-F1C62306BEC5
因此,TH掩码仅用于将日期转换为字符串以进行显示。不带字符串并将其转换为日期!
Datetime suffixes are valid only to format output
https://docs.oracle.com/en/database/oracle/oracle-database/21/sqlrf/Format-Models.html#GUID-515DFB76-E853-432F-BFEC-F1C62306BEC5
因此,TH掩码仅用于将日期转换为字符串以进行显示。不带字符串并将其转换为日期!
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




