如何在 DB2 AS/400 中将十进制字段转换为日期字段? [英] How do I cast a decimal field to a date field in DB2 AS/400?
本文介绍了如何在 DB2 AS/400 中将十进制字段转换为日期字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 DECIMAL 字段,其中包含 AS400 格式的日期:1100614
I have a DECIMAL field which contains a date in the AS400 format: 1100614
我试过了:
cast (MYDATE as DATE)
但我无法将 DECIMAL 转换为 DATE,而
but I can't cast a DECIMAL to DATE, whereas
DATE(MYDATE)
返回空值.
如何将此字段转换为 DATE 字段?
How do I cast this field in a DATE field?
推荐答案
假设它是 CYYMMDD,就像我在上面的评论中问的那样,这里有几个选项:
Assuming it is CYYMMDD like I asked in my comment above, here are a couple options:
可以做到,但并不容易.如果您需要经常执行此操作,可能值得您花时间编写自己的函数来执行此操作.
It can be done, but it isn't easy. If you need to do this often, it may be worth your time writing your own function to do this.
这篇关于如何在 DB2 AS/400 中将十进制字段转换为日期字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文