ASP要怎样才能正确写入SQL数据库的日期?

来源:百度知道 编辑:UC知道 时间:2024/06/30 02:47:22
当我在asp+SQL中使用
sql="update [table] set 日期="&date()&" where XXX=yyy"
conn.execute sql
时会在SQL数据库中写入日期为1905-5-28,
要怎样才能正确写入SQL数据库的日期?

sql="update [table] set 日期=getdate() where XXX=yyy"

sql ="update [table] set 日期="&getdate()&"where xxx=yyy"
getdate()函数返回的是服务器的当前日期。
http://technet.microsoft.com/zh-cn/library/ms188383.aspx
微软的官方网站上有详尽的介绍,如果你不明白的话,可以到上面去了解下

sql="update [table] set 日期="&date()&" where XXX=yyy"
这样并没问题,是你服务器本身时间错误

sql="update [table] set 日期=getdate() where XXX=yyy"