如何在忽略时间的情况下只比较时间戳的日期?
我只想比较月/日/年。例如:
select * from Batch
where openingtime <> closingtime
问题是这会显示太多批处理,因为它将包括 OpeningTime
和 ClosingTime
仅在一天中的时间不同的批处理:
OpeningTime = 2010-07-07 11:19:29.000
ClosingTime = 2010-07-07 19:19:22.000
最佳答案
将两个时间戳都转换为日期
对于 SQL Server
Select *
from Batch
where cast(openingtime as date) <> cast(closingtime as date)
甲骨文
Select *
from Batch
where trunc(openingtime) <> trunc(closingtime)
关于SQL:如何在忽略时间的情况下比较日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31394550/