【发布时间】:2012-10-07 09:53:33
【问题描述】:
我在 SQL Server 2008 中有一个名为 ,timestamplog which contains one column of name LogTime of typeINTEGER 的表`
数值是这样的:
1350468610,
1350468000,
1350381600,
1350295810
我需要介于 1350468609 和 1350468001.. 之间的值。
请告诉我如何查询这些值。
我尝试了以下查询
select LogTime
from timestamplog
where LogTime between 1350468609 and 1350468001
select LogTime
from timestamplog
where LogTime >= '1350468610' and LogTime <= '1350468000'
select LogTime
from timestamplog
where LogTime >= convert(decimal, 1350468610) and LogTime <= convert(decimal,1350468000)
select LogTime
from timestamplog
where LogTime >= convert(varchar, 12) and LogTime <= convert(varchar, 14)
但是行不来了……
实际上表中的值是在表TIMELOG中存储为INTEGER的时间戳值
IMP 注意:假设如果像 12,13,14 这样的值进入表,上述查询工作正常。但是当我比较长度为 10 的数字时,查询不会检索到任何值
感谢提前
【问题讨论】:
标签: sql-server range between timestamp datetime2