如何在SQL合并日期+时间,然后相减呢?
这图来自表opdate
想要把左边的receivedate和receivetime合并为一个完整的datetime字段dt1
把右边的operatedate和operatetime合并为为一个完整的datetime字段dt2
然后拿dt2-d1,求出所有dt2-dt1大于24小时的数据
请问如何实现啊感激不尽!
------解决方案--------------------select * from tb where datediff(day,convert(varchar(100),col1,23)+' '+col2,convert(varchar(100),col3,23)+' '+col4)>1
------解决方案--------------------SELECT * FROM tb
WHERE DATEDIFF(HOUR, ReceiveDate+' '+ReceiveTime, OperateDate+' '+OperatorTime)>24