当前位置:首页 > ASP教程 > 应用技巧

Insert Date and Time into Access

 <%
function accessdatetime (dateandtime)
dim myday
dim mymonth
dim myyear

myday = day(dateandtime)
if len(myday)=1 then myday="0" & myday

mymonth = month(dateandtime)
if len(mymonth)=1 then mymonth="0" & mymonth

myyear = year(dateandtime)

accessdatetime = myyear & "-" & mymonth & "-" & myday & " " & time()
end function

dim connection
dim sql, sconnstring

sql="insert into tbldate (ddate) values (#" & accessdatetime(now()) & "#)"

sconnstring="provider=microsoft.jet.oledb.4.0;" & _
"data source=" & server.mappath("datedb.mdb")
set connection = server.createobject("adodb.connection")
connection.open(sconnstring)
connection.execute(sql)

connection.close
set connection = nothing
%>

【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:)!