如何在 Toad for Oracle 中显示当前日期和时间?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5640697/
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 Do I display current date and time in Toad for Oracle?
提问by Justin
I have a sql statement that counts the units(cable boxes) that were refurbished (had damaged parts replaced) and total units(cable boxes that just went through refurb and had nothing replaced) and it's supposed to do this count regularly (every time a unit is processed the count). Can someone please help me? Thank you.
我有一个 sql 语句,它计算翻新(更换损坏部件)的单位(电缆盒)和总单位(刚刚经过翻新但没有更换的电缆盒),它应该定期进行此计数(每次单位处理计数)。有人可以帮帮我吗?谢谢你。
Justin
贾斯汀
Heres my sql code so far:
到目前为止,这是我的 sql 代码:
SELECT COUNT(*)
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date >?
SELECT COUNT(*) FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date >?
回答by a_horse_with_no_name
SELECT COUNT(*)
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB'
and created_date > sysdate
To exclude the time that is part of any oracle DATE column, you would need to use this:
要排除属于任何 oracle DATE 列的时间,您需要使用以下命令:
SELECT COUNT(*)
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB'
and trunc(created_date) > trunc(sysdate)
回答by d5e5
I think you want the current date and time when you run the query, which is not the same as created_date, right?
我认为您需要运行查询时的当前日期和时间,这与 created_date 不同,对吗?
select COUNT(*),
to_char(sysdate, 'Dy DD-Mon-YYYY HH24:MI:SS') as "Current Time"
FROM cxadminn.repair_part
WHERE repair_type = 'REFURB'
I removed the and created_date >?
from the WHERE clause because it doesn't make sense to me, unless you can have items in your table whose created_date is in the future.
我and created_date >?
从 WHERE 子句中删除了 ,因为它对我来说没有意义,除非您的表中可以拥有其 created_date 是将来的项目。
回答by Gudinya
SELECT COUNT(*) FROM cxadminn.repair_part
WHERE repair_type = 'REFURB' and created_date > sysdate
or
或者
created_date > to_date('01.01.11 01:01:01', 'dd.mm.yyyy hh:mi:ss')