我想从 ms 访问数据库中读取日期时间。
该列的数据类型为 DATETIME,值为:1/27/12 5:10 PM
<html>
<body>
<%
Dim Conn
Dim Rs
Dim sql
Dim sConnection
Dim Today as Date //this gives error - unexpected end of file , i want to display current date and time ???
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
filepath= Server.MapPath ("mydb.mdb")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & filepath
Conn.Open(sConnection)
sql="select * from items;"
Set Rs = Conn.Execute(sql)
if Rs.EOF then
Response.write("No records found")
else
do until rs.eof
ctime = rs("itemadditiondatetime")
Response.write("<br/>Time : <input name='dateandtime[]' value=" & ctime & "/>" & ctime )
rs.movenext
loop
end if
Rs.Close
Conn.Close
Set Rs = Nothing
Set Conn = Nothing
%>
</body>
</html>
在所有文本框中,仅显示日期( 1/27/12 ),不显示时间,但是当我在没有文本框的情况下显示时,将显示整个日期时间。另外我如何在两个文本框中分别获取日期和时间。
另外,我需要将日期格式化为 yyyy-mm-dd。