道教法咒指法:ASP SQL日期比较查询语句的问题.

来源:百度文库 编辑:高校问答 时间:2024/04/25 15:25:17
表中有一字段是日期型的,值是类似这样的:2006-02-05 12:34:45 的值,
如果判断此条信息是今天发布的呢?
sql="select count(uregdate) as xxts from dtt_users where Convert(DateTime,uregdate)=Date()"这样写不行.
Set rsx= Server.CreateObject("ADODB.Recordset")
sql="select count(uregdate) as xxts from dtt_users where convert(char,uregdate,102)=convert(char,getdate(),102)"
rsx.open sql,conn,1,1

大家帮我看看,这样还是出错.不正确.

现在就是说,有一个表,里面有一字段,是日期型的,但是日期的格式是精确到秒的那种,如何统计一下,今天发布的信息数量有多少条.就要实现这样的.我统计好几次,在网上查找都不成功.有一次统计结果却是0.

sql="select count(uregdate) as xxts from dtt_users where datediff('d',uregdate,Date())=0"
用这个吧.

select * from employee

where convert(char,uregdate,102)=convert(char,getdate(),102)

用datediff函数,细节兄弟们来补充。

楼上的应该对吧/ 102 | yy-mm-dd