我如何比较时间戳的日期而忽略时间呢?
我只想比较一下月/日/年。例如:
select * from Batch
where openingtime <> closingtime
问题是,这将显示出太多的批次,因为它将包括OpeningTime
和ClosingTime
仅在一天中不同的批:
OpeningTime = 2010-07-07 11:19:29.000
ClosingTime = 2010-07-07 19:19:22.000
发布于 2015-07-13 22:30:49
将两个时间戳转换为日期
用于SQL Server
Select *
from Batch
where cast(openingtime as date) <> cast(closingtime as date)
甲骨文
Select *
from Batch
where trunc(openingtime) <> trunc(closingtime)
发布于 2015-07-14 06:28:09
另一种方式
Select * from Batch where
CONVERT(VARCHAR(10),openingtime,110<>CONVERT(VARCHAR(10),closingtime,110)
发布于 2015-08-29 17:02:07
Select * from Batch where
CONVERT(VARCHAR(10),openingtime,110)<>CONVERT(VARCHAR(10),closingtime,110)
**There will be a closing bracket** @Miyamoto Musashi
https://stackoverflow.com/questions/31394550
复制相似问题