Oracle to_date()错误输出 [英] Oracle to_date() incorrect output

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

问题描述

必须有一个非常简单的答案,但我在任何地方都找不到.

There must be a very simple answer, but I can't find it anywhere.

我有以下内容是我的select语句的一部分:

I have the following which is a section of my select statement:

       case when q.renewal_date is not null then
            to_date(q._renewal_date, 'DD/MM/YYYY')
       else
            to_date(w.END_DATE, 'DD/MM/YYYY')
       end END_DATE,

根据所有文档,我可以找到MM应该给出月份的数字,但是我得到的结果如下:

according to all of the docs I can find the MM should give the month in numbers however I'm getting results such as:

30-SEP-12
26-JUN-11
30-SEP-12

有趣的是,它们用连字符(-)而不是斜线(/).

It's also interesting that they're hyphenated (-) and not with slashes (/).

那是什么原因?如何实现我想要的目标?

So what's the reason for this and how do I achieve what I want?

推荐答案

假设w.end_Dateq._renewal_date是实际日期,则要to_char而不是to_date.目前,我想说的是您看到的是NLS设置所指定格式的日期. (如果它们不是日期,则将它们转换为日期,但仍然让您的NLS设置选择查看日期的格式)

Assuming w.end_Date and q._renewal_date are actual dates, you want to to_char them, not to_date. At present I would say you are seeing the dates in the format specified by your NLS settings. (If they are not dates, you are converting them to dates, but still letting your NLS settings choose the format you view it in)

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

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