按日期查询问题?

wenle 2008-01-08 10:30:19
在数据库中日期字段MatchDate的值为:2008-01-08 09:59:05.267
我要查询2008-01-08的数据怎么写SQL语句?
例如:
select * from table1 where matchdate = ?
...全文
95 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zefuzhang2008 2008-01-08
  • 打赏
  • 举报
回复
declare @a table (dt datetime)
insert into @a select '2008-01-08 09:59:05.267'
insert into @a select '2008-01-08 00:59:05.267'
insert into @a select '2008-01-08 12:59:05.267'
insert into @a select '2008-01-08 23:59:05.267'

select * from @a where dt> ='2008-01-08' and dt <'2008-01-09'
zefuzhang2008 2008-01-08
  • 打赏
  • 举报
回复
declare @a table (dt datetime)
insert into @a select '2008-01-08 09:59:05.267'
insert into @a select '2008-01-08 00:59:05.267'
insert into @a select '2008-01-08 12:59:05.267'
insert into @a select '2008-01-08 23:59:05.267'

select * from @a where
dt>='2008-01-08' and dt<'2008-01-08'
wzy_love_sly 2008-01-08
  • 打赏
  • 举报
回复
declare @a table (dt datetime)
insert into @a select '2008-01-08 09:59:05.267'

select * from @a where
datediff(dd,dt,'2008-01-08')=0
wzy_love_sly 2008-01-08
  • 打赏
  • 举报
回复
select * from table1 where datediff(dd,matchdate,'2008-01-08')=0
liangCK 2008-01-08
  • 打赏
  • 举报
回复
select * from table1 where convert(char(10),matchdate,120)='2008-01-08'
liangCK 2008-01-08
  • 打赏
  • 举报
回复
select * from table1 where matchdate='2008-01-08'
JL99000 2008-01-08
  • 打赏
  • 举报
回复
在数据库中日期字段MatchDate的值为:2008-01-08 09:59:05.267
我要查询2008-01-08的数据怎么写SQL语句?
例如:
select * from table1 where matchdate = ?

select * from table1 where convert(varchar(10),matchdate,120) ='2008-01-08'

接分
JiangHongTao 2008-01-08
  • 打赏
  • 举报
回复
convert(char(10),matchdate,120)='2008-01-08'

22,295

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧