您的位置:程序门 -> web 开发 -> asp



关于判断一个时间段是否在其他三个时间段的问题(急!!!!!!!!!!!)


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于判断一个时间段是否在其他三个时间段的问题(急!!!!!!!!!!!)
发表于:2007-05-22 02:47:15 楼主
比如一个时间段:xxx--xxxx
是否在5.1-6.15   or   9.17-9.30   or   10.9-10.31
如果这个时间段在这三个时间段之一   则继续下面的语句

拜托大家了   急死我了!!!多给点分
发表于:2007-05-22 03:13:491楼 得分:0
starttime= "5月20日 "
endtime= "5月22日 "
if   datediff( "d ",cdate(rs2( "time1 ")),starttime) <0   or   datediff( "d ",cdate(rs2( "time2 ")),endtime)> 0   then
response.write   "执行 "
else
response.write   "不执行 "
end   if
这个是我想的一个的   三个怎么弄呢?
发表于:2007-05-22 03:19:192楼 得分:0
<%   dim   m,d
m=month(now)
d=day(now)
if   (m=5   or   (m=6   and   d <=15))   or   (m=9   and   d> =17   and   d <=30)   or   (m=10   and   d> =9   and   d <=31)   then
response.write( "ok ")
end   if
  %>
发表于:2007-05-22 08:14:513楼 得分:0
(xxx> =5.1   and   xxxx <=6.15)   or   ...
上面的比较用日期函数。
发表于:2007-05-22 09:13:314楼 得分:0
5.1-6.15   or   9.17-9.30   or   10.9-10.31
这3个时间段分别夹击不就行了吗
首先保证程序能运行,其次再考虑方法的好坏
发表于:2007-05-22 09:31:465楼 得分:0
对,先保证你的程序能正确运行,再去思考怎么样做到最好,这是很重要的。
不然你东西始终会出不来,而一个出来的东西,是不能用好坏来衡量的。
发表于:2007-05-22 09:34:426楼 得分:0
'5.1-6.15   or   9.17-9.30   or   10.9-10.31

dd=cdate(2005-5-3)
if   checkdate(dd)   then
      ....
end   if

function   checkdate(vdate)
    dim   chkdate(2,1)
    chkdate(0,0)= "5-1 "
    chkdate(0,1)= "6-15 "
    ....
    for   i=0   to   ubound(chkdate)
          if   vdate> =cdate(year(vdate)& "- "&chkdate(i,0))   and   vdate <=cdate(year(vdate)& "- "&chkdate(i,1))   then
                checkdate=true
                exit   function
          end   if
    next
    checkdate=false;
    next
end   function
发表于:2007-05-22 09:43:457楼 得分:0
starttime= "5月20日 "
endtime= "5月22日 "
if   datediff( "d ",cdate(rs2( "time1 ")),starttime) <0   or   datediff( "d ",cdate(rs2( "time2 ")),endtime)> 0   then
//这里给一个int   i++
else
//不做任何事
end   if
三段代码都是这样,最后判断i的值,等于0则什么都不执行,大于0就执行阿
发表于:2007-05-22 11:04:358楼 得分:0

<%   dim   m,d
m=month(cdate(rs2( "time1 ")))
d=day(cdate(rs2( "time1 ")))
if   (m=5   or   (m=6   and   d <=15))   or   (m=9   and   d> =17   and   d <=30)   or   (m=10   and   d> =9   and   d <=31)   then
response.write( "ok ")
end   if
  %>

主要是简单有效



快速检索

最新资讯
热门点击