没有合适的资源?快使用搜索试试~ 我知道了~
对SQL Server2000取数据时间日期的一般性总结
资源推荐
资源详情
资源评论
#以下时间均为:20071130235959
# 5分钟
declare @time1 varchar(20),@time2 varchar(20)
# 当前时间减去5分钟
select @time1=replace(replace(replace(CONVERT(varchar, dateadd(mi,-5,getdate()), 120 ),'-',''),' ',''),':','')
# 当前时间
select @time2=replace(replace(replace(CONVERT(varchar,dateadd(mi,-0,getdate()), 120 ),'-',''),' ',''),':','')
select count(dOctets) from Raw_V5 where stamp between @time1 and @time2
一天
#24小时统计,只要在晚上12点执行就可以统计当天的记录,
declare @time1 varchar(20),@time2 varchar(20)
#前一天 20071209000000
select @time1=replace(replace(replace(convert(varchar(18),(CONVERT(varchar(10), dateadd(mi,-1440,getdate()), 120 ))+'000000',120),'-',''),' ',''),':','')
#前一天 20071209235959
select @time2=replace(replace(replace(convert(varchar(18),(CONVERT(varchar(10),dateadd(mi,-1440,getdate()), 120 ))+'235959',120),'-',''),' ',''),':','')
select count(dOctets) from Raw_V5 where stamp between @time1 and @time2
月份
#上一个月的第一天 20071101000000
select replace(replace(replace(CONVERT(varchar,CONVERT(datetime,CONVERT(char(8),dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)),120)+'1'), 120 ),'-',''),' ',''),':','')
#上一个月的最后一天 20071130235959
select replace(replace(replace(CONVERT(varchar,dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)), 120 ),'-',''),' ',''),':','')
# 5分钟
declare @time1 varchar(20),@time2 varchar(20)
# 当前时间减去5分钟
select @time1=replace(replace(replace(CONVERT(varchar, dateadd(mi,-5,getdate()), 120 ),'-',''),' ',''),':','')
# 当前时间
select @time2=replace(replace(replace(CONVERT(varchar,dateadd(mi,-0,getdate()), 120 ),'-',''),' ',''),':','')
select count(dOctets) from Raw_V5 where stamp between @time1 and @time2
一天
#24小时统计,只要在晚上12点执行就可以统计当天的记录,
declare @time1 varchar(20),@time2 varchar(20)
#前一天 20071209000000
select @time1=replace(replace(replace(convert(varchar(18),(CONVERT(varchar(10), dateadd(mi,-1440,getdate()), 120 ))+'000000',120),'-',''),' ',''),':','')
#前一天 20071209235959
select @time2=replace(replace(replace(convert(varchar(18),(CONVERT(varchar(10),dateadd(mi,-1440,getdate()), 120 ))+'235959',120),'-',''),' ',''),':','')
select count(dOctets) from Raw_V5 where stamp between @time1 and @time2
月份
#上一个月的第一天 20071101000000
select replace(replace(replace(CONVERT(varchar,CONVERT(datetime,CONVERT(char(8),dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)),120)+'1'), 120 ),'-',''),' ',''),':','')
#上一个月的最后一天 20071130235959
select replace(replace(replace(CONVERT(varchar,dateadd(ms,-3,DATEADD(mm, DATEDIFF(mm,0,getdate()), 0)), 120 ),'-',''),' ',''),':','')
资源评论
waterloovx
- 粉丝: 0
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功