SQL 如何只显示oracle中的时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1568406/
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
how to show only the time in oracle?
提问by Gold
I have table that has date field. When I run a query, I see this:
我有带有日期字段的表。当我运行查询时,我看到:
01/10/2009 22:10:39
01/10/2009 22:10:39
How can I retrieve only the time (IE: 22:10:39)
我怎样才能只检索时间(IE:22:10:39)
回答by Amirshk
you can try this:
你可以试试这个:
SELECT TO_CHAR(yourval, 'DD-MON-YYYY HH:MI:SS') FROM yourtable;
SELECT TO_CHAR(yourval, 'HH:MI:SS') FROM yourtable;
Edit:as @steven pointed out, to have 24 hours style use
编辑:正如@steven 指出的,要使用 24 小时风格
SELECT TO_CHAR(yourval, 'HH24:MI:SS') FROM yourtable;
回答by Steven
You need the format HH24
, since HH
is only a 12 hour date.
您需要 format HH24
,因为HH
它只是一个 12 小时的日期。
select to_char(SYSDATE, 'HH24:MI:SS') from dual
select to_char(YourDateColumn, 'HH24:MI:SS') from YourTable
回答by Henry Gao
SELECT TO_CHAR (SYSDATE, 'hh:mi:ss') FROM DUAL
SELECT TO_CHAR (SYSDATE, 'hh:mi:ss') FROM DUAL
回答by Haid
SELECT TO_CHAR(DATE_COLUMN,'HH24:MI:SS') from TABLE;
从表中选择 TO_CHAR(DATE_COLUMN,'HH24:MI:SS');