首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

跪求一条sql语句,怎么取得"今日"的发表的数量

2012-02-08 
跪求一条sql语句,如何取得今日的发表的数量数据库是MS-sql简单的描述就是这样:在表里,字段有:idtitlecon

跪求一条sql语句,如何取得"今日"的发表的数量
数据库是MS-sql
简单的描述就是这样:在表里,
字段有:id     title     content     createTime
createTime   是发表时间,datetime类型
取得发表的文章的全部数量可以用sum,
可是要取得今日的发表数量,如何写这个sql语句??(比如取得今天8月27日发表的文章数量)


兄弟们帮帮忙,立刻给分!

[解决办法]
select count(*) from tablename where createTime > =getdate()
[解决办法]
这样更准一些:
select count(*) from tablename where createTime> =Convert(datetime,year(getdate())+ '- '+month(getdate())+ '- '+day(getdate()))
[解决办法]
select count(*) from tablename where convert(char(10),createTime,20) = convert(char(10),getdate(),20)
[解决办法]
select count(*) from tablename where createTime > =getdate().toshortstring()

[解决办法]
select count(id) from tablename where createTime> = CAST(SUBSTRING(CAST(StartDateTime AS VarChar), 0, 11) AS DateTime) AND createTime < DATEADD(Day,1,CAST(SUBSTRING(CAST(StartDateTime AS VarChar), 0, 11) AS DateTime))
[解决办法]
select count(id) from tablename where createTime> = CAST(SUBSTRING(CAST(getdate() AS VarChar), 0, 11) AS DateTime) AND createTime < DATEADD(Day,1,CAST(SUBSTRING(CAST(getdate() AS VarChar), 0, 11) AS DateTime))

热点排行