oracle中to_date() 函数得到的日期 如果相减得到的是结果天,可以是天, oracle表的date类型在达梦中都转成了timestamp类型, 那这个timestamp - sysdate 得到的不在是天了, 那我怎么办 select to_date(to_char(to_timestamp('2024-11-19 08:00:00','yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss') - sysdate from dual; 这样转么? 有没有什么简单的方法, 我就是想知道两个日期相差的天数
https://eco.dameng.com/document/dm/zh-cn/pm/function#8.3%20%E6%97%A5%E6%9C%9F%E6%97%B6%E9%97%B4%E5%87%BD%E6%95%B0
你好,日期函数的使用请参考以上链接
请问是要整数天数,参考 SELECT DATEDIFF(dd,sysdate, to_date(to_char(to_timestamp('2024-11-20 00:00:00','yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss'));
达梦的to_date函数, 如果select to_date('2024-11-19 08:10:10', 'yyyy-mm-dd hh24:mi:ss') from dual; 这样直接查询,显示的2024-11-19 只有年月日, 但是 select to_date('2024-11-19 08:10:10', 'yyyy-mm-dd hh24:mi:ss') - sysdate from dual; 得到的是 0.8944791666666667 , select to_date('2024-11-19 08:10:10', 'yyyy-mm-dd hh24:mi:ss') - to_date('2024-11-19 00:00:00', 'yyyy-mm-dd hh24:mi:ss') from dual; 得到的是 0.3403935185185185 这样看来to_date结果也包含了时分秒?