SQLSERVER特定时间段查询
select*frommeet_nowwheremeetdatebetweenCONVERT(datetime,'2008-07-24',111)andconvert(d...
select * from meet_now where meetdate between CONVERT(datetime , '2008-07-24', 111 ) and convert(datetime , '2008-07-25', 111 ) and order by id 能通过SQL查询分析器,怎么能修改成只查询表中某一天的数据?'2008-07-24处修改成参数类型的?
meetdate是从页面自动获取的时间.
查询条件是根据meetdate字段中的时间,得到表meet_now的内容,每2天从表meet_now取数据.
修改成这样老有语法错误,怎么修改才能通过编译?
SELECT count(*) FROM (SELECT * FROM meet_now WHERE meetdate = convert(datetime,'yyyy-mm-dd'+ 1) -
convert(datetime,'yyyy-mm-dd')) 展开
meetdate是从页面自动获取的时间.
查询条件是根据meetdate字段中的时间,得到表meet_now的内容,每2天从表meet_now取数据.
修改成这样老有语法错误,怎么修改才能通过编译?
SELECT count(*) FROM (SELECT * FROM meet_now WHERE meetdate = convert(datetime,'yyyy-mm-dd'+ 1) -
convert(datetime,'yyyy-mm-dd')) 展开
2个回答
展开全部
DECLARE @dt DATETIME
DECLARE @dt2 DATETIME
SET @dt = '2008-07-24'
SET @dt2 = DATEADD(day, 1, @dt)
select @dt as dt, @dt2 as dt2
select * from meet_now where meetdate between CONVERT(datetime , @dt, 111 ) and convert(datetime , @dt2, 111 ) order by id
select * from meet_now where DATEDIFF(day, meetdate, @dt) = 0 order by id
DECLARE @dt2 DATETIME
SET @dt = '2008-07-24'
SET @dt2 = DATEADD(day, 1, @dt)
select @dt as dt, @dt2 as dt2
select * from meet_now where meetdate between CONVERT(datetime , @dt, 111 ) and convert(datetime , @dt2, 111 ) order by id
select * from meet_now where DATEDIFF(day, meetdate, @dt) = 0 order by id
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询