SQL中如何查询当天的数据。

luxunyangyong 2010-11-07 04:50:43
想查询一天添加了多少条数据。。。。



如 table1

id name addtime

其中,addtime 的格式为 2007-09-28 14:38:23.890

...全文
1154 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
黄_瓜 2010-11-07
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 luxunyangyong 的回复:]
select count(1) from tb where datediff(dd,addtime,getdate())=0



select
convert(varchar(10),addtime,120),count(1)
from
tb
where
datediff(dd,addtime,getdate())>=0
group by
convert(varc……
[/Quote]试试就知道了。
luxunyangyong 2010-11-07
  • 打赏
  • 举报
回复
谢谢谢谢!!!!
luxunyangyong 2010-11-07
  • 打赏
  • 举报
回复
select count(1) from tb where datediff(dd,addtime,getdate())=0



select
convert(varchar(10),addtime,120),count(1)
from
tb
where
datediff(dd,addtime,getdate())>=0
group by
convert(varchar(10),addtime,120)


区别是??
--小F-- 2010-11-07
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 luxunyangyong 的回复:]
就是当天到查询那一刻。。。
[/Quote]

select
convert(varchar(10),addtime,120),count(1)
from
tb
where
datediff(dd,addtime,getdate())>=0
group by
convert(varchar(10),addtime,120)
飘零一叶 2010-11-07
  • 打赏
  • 举报
回复
你们干嘛要这么快那
luxunyangyong 2010-11-07
  • 打赏
  • 举报
回复
就是当天到查询那一刻。。。
--小F-- 2010-11-07
  • 打赏
  • 举报
回复
select
convert(varchar(10),addtime,120),count(1)
from
tb
group by
convert(varchar(10),addtime,120)
--小F-- 2010-11-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 rucypli 的回复:]
SQL code
select convert(varchar(10),addtime,120),count(*)
from tb
group by convert(varchar(10),addtime,120)
[/Quote]

我看成当天了
ForFumm 2010-11-07
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 rucypli 的回复:]
SQL code
select convert(varchar(10),addtime,120),count(*)
from tb
group by convert(varchar(10),addtime,120)
[/Quote]
up
rucypli 2010-11-07
  • 打赏
  • 举报
回复
select convert(varchar(10),addtime,120),count(*)
from tb
group by convert(varchar(10),addtime,120)
--小F-- 2010-11-07
  • 打赏
  • 举报
回复
select count(1) from tb where datediff(dd,addtime,getdate())=0

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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