ASP代码 往数据库中添加时分秒的问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 20:18:44
<td colspan="2"><select name="AlarmTime" id="AlarmTime">
<option selected>2006</option>
<option>2007</option>
<option>2008</option>
<option>2009</option>
<option>2010</option>
</select>

<select name="AlarmTime" id="AlarmTime">
<option selected>01</option>
<option>02</option>
...
<option>12</option>
</select>

<select name="AlarmTime" id="AlarmTime">
<option selected>01</option>
<option>02</option>
...
<option>31</option>
</select>

<select name="AlarmTime" id="AlarmTime">
<option selected>0

必须把得到的AlarmTime转换成时间格式,才能写入到数据库,具体使用函数
AlarmTime=FormatDateTime(AlarmTime,0)

把你的AlarmTime改掉,不要全部的select都用同一个value值,这样会冲突,比如年就用years ,月用months ,天用days,小时用hours ,分钟用minutes ,秒用seconds ,然后得到:
years=request("years")
months=request("months")
days=request("days")
hours=request("hours")
minutes=request("minutes")
seconds=request("seconds")
tempstr1=years&"-"&months&"-"&days&" "&hours&":"&minutes&":"&seconds&""
AlarmTime=FormatDateTime(tempstr1,0)