央视影音手机视频导出:关于SQL日期转换的问题?

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 20:39:56
在MSSQL里面的时期字段的"默认值"用"getdate()"得到时间.
但是格式是:2006-6-20 0:15:00
网上找到可以用:select CONVERT(varchar(12),infotime, 111 )
转换.但是不知道怎么用?

<!--#include file="conn.asp"-->
<%sql="select * from news"
set rs=server.CreateObject("adodb.recordset")
rs.open sql,conn,1,1
%>
<%
while not rs.eof
infotime=rs("infotime")
infotime=select CONVERT(varchar(12),infotime, 111 )
response.write infotime%></br>
<%rs.movenext
wend%>

这样会报语法错误,请问正确的应该怎样写?或者可否在数据库中直接处理日期的格式?

\'output->6/20/2006
response.write(FormatDatetime(rs(\"infotime\"), 0))

\'output->Tuesday, June 20, 2006
response.write(FormatDatetime(rs(\"infotime\"), 1))

\'output->6/20/2006
response.write(FormatDatetime(rs(\"infotime\"), 2))

\'output->0:15:00 AM
response.write(FormatDatetime(rs(\"infotime\"), 3))

\'output->0:15
response.write(FormatDatetime(rs(\"infotime\"), 4))