使用substr时出现to_date错误 [英] to_date error while using substr

查看:157
本文介绍了使用substr时出现to_date错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我跑步时:

select to_date('substr(21120319,3)','YYMMDD') 
from dual 

我遇到了错误:

日期不在有效范围-4719和+9999之间.

date is not in the valid range -4719 and +9999.

但是如果这样做:

select to_date('120319','YYMMDD') 
from dual

我的查询运行正常,并给出输出19-MAR-12.

my query runs fine and gives ouput 19-MAR-12.

此错误的原因是什么.请帮助我理解这一点.

What is the reason for this error. Please help me understand this.

感谢您的宝贵时间.

推荐答案

您必须从字符串文字中删除substr.

you have to remove substr from the string literal.

select to_date(substr('21120319', 3),'YYMMDD') 
from dual ;

这篇关于使用substr时出现to_date错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆