导航
  • 主页
  • 基础类
  • 应用实例
  • 新技术前沿

求一个简单的时间查询~~~

yowbell 2008-01-10 11:44:47


时间戳
------------------
01 1 2008 6:00AM
01 2 2008 6:00AM
01 3 2008 6:00AM
01 4 2008 6:00AM
01 5 2008 6:00AM
01 6 2008 6:00AM
01 7 2008 6:00AM
01 8 2008 6:00AM
01 9 2008 6:00AM
01 10 2008 6:00AM
12 29 2007 6:00AM
12 30 2007 6:00AM
12 31 2007 6:00AM

如何查出二天前的记录?
...全文
69 点赞 收藏 7
写回复
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yowbell 2008-01-13
感谢各位~~
回复
pt1314917 2008-01-10

这样?
select * from @t where datediff(dd,time,getdate())>2
回复
chuifengde 2008-01-10
select * from [Table] where dateadd(day,2,时间戳)<getdate()
回复
zywinner168 2008-01-10
学习
回复
shirley_yue 2008-01-10
够细的哦
回复
dawugui 2008-01-10
时间戳
------------------
01 1 2008 6:00AM
01 2 2008 6:00AM
01 3 2008 6:00AM
01 4 2008 6:00AM
01 5 2008 6:00AM
01 6 2008 6:00AM
01 7 2008 6:00AM
01 8 2008 6:00AM
01 9 2008 6:00AM
01 10 2008 6:00AM
12 29 2007 6:00AM
12 30 2007 6:00AM
12 31 2007 6:00AM

如何查出二天前的记录?

--两天前
select * from tb where datediff(day,2,时间戳) >= 2
--48小时前
select * from tb where datediff(hour,48,时间戳) >= 48
回复
JL99000 2008-01-10
if object_id('tb') is not null
drop table tb
go
create table tb(时间戳 datetime)
insert tb
select '01 1 2008 6:00AM' union all
select '01 2 2008 6:00AM' union all
select '01 3 2008 6:00AM' union all
select '01 4 2008 6:00AM' union all
select '01 5 2008 6:00AM' union all
select '01 6 2008 6:00AM' union all
select '01 7 2008 6:00AM' union all
select '01 8 2008 6:00AM' union all
select '01 9 2008 6:00AM' union all
select '01 10 2008 6:00AM' union all
select '12 29 2007 6:00AM' union all
select '12 30 2007 6:00AM' union all
select '12 31 2007 6:00AM'
select * from tb
select * from tb where dateadd(day,2,时间戳)<getdate()
回复
发动态
发帖子
MS-SQL Server
创建于2007-09-28

3.2w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
社区公告
暂无公告