小编Ree*_*man的帖子

如何在 Oracle 中将年份格式“yy”转换为“yyyy”

我试图将值从表 G0DM 插入到 G0RDM。我面临的问题是 GODM 表中 DOJS 列中的日期被指定为“01-01-00”格式。年份值输入为“00”,需要显示为 2000。我尝试更改数据库手动输入,但即使我尝试过,错误也会不断出现。其他与日期相关的列也有同样的问题。所以手动更改它是如此困难..

我的查询:

INSERT INTO g0rdm
            (aud_number,
             short_code,
             entitlement_number,
             abbrevi,
             name,
             designation,
             person_charge,
             office_name,
             place,
             dob,
             dojs)
SELECT aud_number,
       short_code,
       entitlement_number,
       abbrevi,
       name,
       designation,
       person_charge,
       office_name,
       place,
       To_date(dob, 'dd-mm-yyyy'),
       To_date(dojs, 'dd-mm-yyyy')
FROM   g0dm; 
Run Code Online (Sandbox Code Playgroud)

错误信息是:

SQL Error: ORA-01841: (full) year must be between -4713 and +9999, and not be 0
01841. 00000 -  "(full) year must be between -4713 and +9999, and not be 0"
*Cause:    Illegal year entered
*Action:   Input year in the …
Run Code Online (Sandbox Code Playgroud)

sql oracle

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

oracle ×1

sql ×1