asp 日期 01-01
场景:关于用ASP提取日期格式有关问题如1-1日怎样提取成01-01日
关于用ASP提取日期格式问题如1-1日怎样提取成01-01日?
如题,我写了一段循环生成月、日的代码如下:
<select name= "month " size= "1 " id= "select3 ">
<%for i=1 to 12 %>
<%if i=month(now()) then%>
<option value= <%=i%> selected> <%=i%> </option>
<%else%>
<option value= <%=i%> > <%=i%> </option>
<%end if%>
<%next%>
</select>
月
<select name= "day " size= "1 " id= "select4 ">
<%for i=1 to 31 %>
<%if i=day(now()) then%>
<option value= <%=i%> selected> <%=i%> </option>
<%else%>
<option value= <%=i%> > <%=i%> </option>
<%end if%>
<%next%>
</select>
日
这样得到的month和day为“1-1、10-5”这样的格式,现希望它能显示为“01-01、10-05”这样的格式,以配合我下面程序根据日期来判断用户星座。应该怎么做?谢谢。
If star_num> =120 and star_num <=218 then
star= "水瓶座 "
Elseif star_num> =219 and star_num <=320 then
star= "双鱼座 "
Elseif star_num> =321 and star_num <=419 then
star= "白羊座 "
Elseif star_num> =420 and star_num <=520 then
star= "金牛座 "
Elseif star_num> =521 and star_num <=621 then
star= "双子座 "
Elseif star_num> =622 and star_num <=722 then
star= "巨蟹座 "
Elseif star_num> =723 and star_num <=822 then
star= "狮子座 "
Elseif star_num> =823 and star_num <=922 then
star= "处女座 "
Elseif star_num> =923 and star_num <=1022 then
star= "天秤座 "
Elseif star_num> =1023 and star_num <=1122 then
star= "天蝎座 "
Elseif star_num> =1123 and star_num <=1221 then
star= "射手座 "
Else
star= "魔羯座 "
End if
------解决方案--------------------
就是這樣.接點分.
------解决方案--------------------
拼字符串然后强转int
ps:那个计算星座的为什么不用SELECT CASE....
------解决方案--------------------
Function FormatDate(Str)
GetDateNow = year(Str)& "- "&right( "0 "&month(Str),2)& "- "&right( "0 "&day(Str),2))
End Function
Response.Write FormatDate( "2007-1-1 ")
------解决方案--------------------
呵呵,又错了,改改
Function FormatDate(Str)
FormatDate = year(Str)& "- "&right( "0 "&month(Str),2)& "- "&right( "0 "&day(Str),2))
End Function
Response.Write FormatDate( "2007-1-1 ")
------解决方案--------------------
if len(y)=1 then y= "0 "&y end if
这里的end if 是多余的
------解决方案--------------------
呵呵,接分……^_^
------解决方案--------------------
再补一点,月份不用处理的~
关于用ASP提取日期格式问题如1-1日怎样提取成01-01日?
如题,我写了一段循环生成月、日的代码如下:
<select name= "month " size= "1 " id= "select3 ">
<%for i=1 to 12 %>
<%if i=month(now()) then%>
<option value= <%=i%> selected> <%=i%> </option>
<%else%>
<option value= <%=i%> > <%=i%> </option>
<%end if%>
<%next%>
</select>
月
<select name= "day " size= "1 " id= "select4 ">
<%for i=1 to 31 %>
<%if i=day(now()) then%>
<option value= <%=i%> selected> <%=i%> </option>
<%else%>
<option value= <%=i%> > <%=i%> </option>
<%end if%>
<%next%>
</select>
日
这样得到的month和day为“1-1、10-5”这样的格式,现希望它能显示为“01-01、10-05”这样的格式,以配合我下面程序根据日期来判断用户星座。应该怎么做?谢谢。
If star_num> =120 and star_num <=218 then
star= "水瓶座 "
Elseif star_num> =219 and star_num <=320 then
star= "双鱼座 "
Elseif star_num> =321 and star_num <=419 then
star= "白羊座 "
Elseif star_num> =420 and star_num <=520 then
star= "金牛座 "
Elseif star_num> =521 and star_num <=621 then
star= "双子座 "
Elseif star_num> =622 and star_num <=722 then
star= "巨蟹座 "
Elseif star_num> =723 and star_num <=822 then
star= "狮子座 "
Elseif star_num> =823 and star_num <=922 then
star= "处女座 "
Elseif star_num> =923 and star_num <=1022 then
star= "天秤座 "
Elseif star_num> =1023 and star_num <=1122 then
star= "天蝎座 "
Elseif star_num> =1123 and star_num <=1221 then
star= "射手座 "
Else
star= "魔羯座 "
End if
------解决方案--------------------
就是這樣.接點分.
------解决方案--------------------
拼字符串然后强转int
ps:那个计算星座的为什么不用SELECT CASE....
------解决方案--------------------
Function FormatDate(Str)
GetDateNow = year(Str)& "- "&right( "0 "&month(Str),2)& "- "&right( "0 "&day(Str),2))
End Function
Response.Write FormatDate( "2007-1-1 ")
------解决方案--------------------
呵呵,又错了,改改
Function FormatDate(Str)
FormatDate = year(Str)& "- "&right( "0 "&month(Str),2)& "- "&right( "0 "&day(Str),2))
End Function
Response.Write FormatDate( "2007-1-1 ")
------解决方案--------------------
if len(y)=1 then y= "0 "&y end if
这里的end if 是多余的
------解决方案--------------------
呵呵,接分……^_^
------解决方案--------------------
再补一点,月份不用处理的~