oracle select sysdate from dual return only date, not time
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35408398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
select sysdate from dual returns only date, not time
提问by vldmrrdjcc
In SqlDeveloper, when I run this query:
在 SqlDeveloper 中,当我运行此查询时:
select sysdate from dual
I see only 15-FEB-16,
我只看到 15-FEB-16,
but not the time portion. I suppose that there is time portion, but somehow I can not see it. How to fix this?
但不是时间部分。我想有时间部分,但不知何故我看不到它。如何解决这个问题?
Thanks.
谢谢。
回答by Jemo
If you don't want/can't change the NLS settings, use the to_char function, but note that since then its a varchar type, not a date anymore! changing it back to date would display it according to NLS settings again
如果您不想/不能更改 NLS 设置,请使用 to_char 函数,但请注意,从那时起它是 varchar 类型,不再是日期!将其改回日期将再次根据 NLS 设置显示它
SELECT to_char(SYSDATE, 'yyyy-mm-dd hh24:mm:ss') from dual
this way you can define the format (using the mask) anyway you want
这样你就可以随意定义格式(使用掩码)
回答by SkyWalker
Change your NLS settings: Tools -> Preferences -> Database -> NLS
更改 NLS 设置:工具 -> 首选项 -> 数据库 -> NLS