ASP,连接两个变量形成日期。

来源:百度知道 编辑:UC知道 时间:2024/06/02 23:05:34
我做的一个页面需要能够让浏览者能够自己设置时间,形式如下:

开始时间:| |:| |
01 00
02 10
03 20
. .
. .

其中| |表示下拉菜单,可以让用户选择不同的小时数和不同的整十分钟数。在数据库那边我之能用一个时间变量来表示以方便另一个文件读取。

想问下我怎么样做去把这个 小时 和 整十分数 连接起来赋值给数据库中的那个时间变量(数据库中的小时数是按00:00这样的格式的)。

用这个试试吧,应该可以,我测试过了
h=request("hour")
m=request("Minute")
time1=h&":"&m
time2=formatdatetime(time1,4)

得到的time2就是你需要的时间了,跟数据库里的格式是一样的
这里的formatdatetime(time1,4)后面一个参数是用来设置时间格式的,设为4就是HH:MM的格式

strhour=hour(变量时间)
strminute=minute(变量分钟)
strmonth=month(变量秒)
if strhour<10 then
strhour="0"&strhour
end if
if strminute<10 then
strminute="0"&strminute
end if
if strmonth<10 then
strmonth="0"&strmonth
end if
if strday<10 then
strday="0"&strday
end if