select count(1) from xxx where UserID=2127 and mydate=getdate()我这里的数据默认就是 getdate()生成的所以数据
都是
2011-6-10 17:50:03
2011-6-10 17:20:06
这样的所以我这里用getdate()也把具体的时间带上去 所以导致 查询的count为0这里如何查询 当天的呢?mydate=?这个地方的条件怎么写哇?
都是
2011-6-10 17:50:03
2011-6-10 17:20:06
这样的所以我这里用getdate()也把具体的时间带上去 所以导致 查询的count为0这里如何查询 当天的呢?mydate=?这个地方的条件怎么写哇?
你这个也查不出来 我先也是这样做的 现在我改成这样就可以查询出来了
不知道有没简单的办法select count(1) from xx where UserID=2127 and (select convert(varchar(10),mydata,120)) = (select convert(varchar(10),getdate(),120))
from xxx
where UserID=2127 and mydate=convert(char(20),getdate(),120)
select count(1) from xxx where UserID=2127 and convert(varchar(10),mydate,120)=convert(varchar(10),getdate(),120)
convert(nvarchar(50),mydate,23)=convert(nvarchar(50),getdate(),23)
select count(1) from xxx where UserID=2127 and mydate=CONVERT(varchar(100), GETDATE(), 23)
另附:http://blog.csdn.net/yubofighting/archive/2010/10/13/5938103.aspx