sql 获取当前日期

来源:百度知道 编辑:UC知道 时间:2024/06/17 01:51:37
在SQL Server中可以用getdate()来自动获取当前时间,但是获取值包括日期和时间,我现在不需要具体时间,只要年-月-日即可,应该用什么代替getdate()?
Microsoft OLE DB Provider for SQL Server (0x80040E07)
将 varchar 值 '2008-11-19' 转换为数据类型为 int 的列时发生语法错误。

用date()这更本不行,用
select convert(varchar(10),getdate(),120)

convert(varchar(10),getdate(),120)
就提示以上错误

if founderr=false and rs("WebClick")=0 then
Name=trim(request.form("Name"))
sql="update [LR_User] set WebClick=1,VipinDate=convert(varchar(10),getdate(),120) ,VipendDate=convert(varchar(10),getdate(),120) +"&viptime&",UserPower=UserPower-"&zvippoints&" where name='"&name&"'"
conn.execute sql
response.Write"<script language=javascript>alert('您申请成功,恭喜您成为"&webname&"的VIP会员');this.location.href='mysite.asp?action=vip';</script>"
end if

是的老大,viptime是什么int的,他的值可以是一天也可以是365天,谢谢你的一直关

select convert(varchar(10),getdate(),120)

convert(varchar(10),getdate(),120)

-------------------------------------

select convert(varchar(10),getdate(),120) 会出错??

你把你的代码都发出来..不是这个的问题.应该是你的sql语句有问题.

'2008-11-19' 怎么样都转不成int的

----------------------------------------
viptime是什么int的吗?? 这里的问题
值是多少??也不能这么直接加吧.
是加一天还是多久??

我给你改一下你的语句

用date()即可