在 Oracle SQL 中计算今天与受雇人员之间的天数?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3129707/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 06:41:28  来源:igfitidea点击:

Count the number of days between today & the hiredate in Oracle SQL?

sqloracleselectdate-arithmetic

提问by LJme

How can I count the number of days between (sysdate) & a column called hiredatein PL/SQL.

如何计算 (sysdate) 与hiredatePL/SQL 中调用的列之间的天数。

Thanks.

谢谢。

回答by akf

You could try the following:

您可以尝试以下操作:

SELECT TRUNC(sysdate) - TRUNC(t.hiredate) FROM myTable t; 

This will result in a count of days represented in decimal. The TRUNCof the timestamps will ensure that you will get a consistent result on successive calls.

这将导致以十进制表示的天数。该TRUNC时间戳将确保你会得到连续调用一个一致的结果。

回答by waqar

select round((months_between(sysdate,hiredate) * 30),0) from table