在线等!急需解决,高分!查询昨天下午16点到今天下午16点的SQL语句!!!求高手解决,感激不
展开全部
select * from tb
where shijian between convert(varchar(10),(dateadd(day,-1,getdate()),120)+' 16:00:00' and convert(varchar(10),(getdate(),120)+' 16:00:00'
where shijian between convert(varchar(10),(dateadd(day,-1,getdate()),120)+' 16:00:00' and convert(varchar(10),(getdate(),120)+' 16:00:00'
更多追问追答
追问
提示
消息 156,级别 15,状态 1,第 1 行
关键字 'where' 附近有语法错误
追答
你要把你的表名 tb和字段shijian名称替换掉
展开全部
select * from 表名
where 字段名 between CAST(CAST(DATEADD(DD,-1,CAST(GETDATE() as date)) AS varchar(10))+' 16:00:00' AS datetime)
and CAST(CAST(CAST(getdate() as DATE)) AS varchar(10))+' 16:00:00' AS datetime)
版本:SQL2008
where 字段名 between CAST(CAST(DATEADD(DD,-1,CAST(GETDATE() as date)) AS varchar(10))+' 16:00:00' AS datetime)
and CAST(CAST(CAST(getdate() as DATE)) AS varchar(10))+' 16:00:00' AS datetime)
版本:SQL2008
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询