比如一个销售单子,里面有订货时间和付款时间2个字段。想找出所有付款时间是订货时间次日18点以后的销售单
另外订货时间和付款时间都是毫秒值,比如2014-01-26 00:00:00是1390665600。
请问这样的sql怎么写?
select * from t_order t where t.pay_date = t.order_date + 多少毫秒值呢?
------解决方案--------------------
这样不行吗?
select * from t_order t where t.pay_date > to_date(to_char(t.order_date+1,'yyyymmdd')
------解决方案--------------------
' 18:00:00','yyyymmdd hh:24:mi:ss')
------解决方案--------------------
试试这样?
select *
from t_order t
where t.pay_date >
(to_date(to_char(t.order_date / (1000 * 60 * 60 * 24) + 1 +
to_date('1970-01-01 08:00:00',
'YYYY-MM-DD HH:MI:SS'),
'YYYY-MM-DD')
------解决方案--------------------
' 18:00:00',
'YYYY-MM-DD HH24:MI:SS') -
to_date('1970-01-01 08:00:00', 'YYYY-MM-DD HH:MI:SS')) * 24 * 60 * 60 * 1000