如何做到下拉列表中显示周工作日时间段?高分相赠!

yhb72 2003-08-03 01:07:02
想做到这样的效果,进入页面后,在页面中的下拉列表框中能列出本年从1月到12月的所有周(或从本年的第一周到当前月的最后一周)?
效果如:2003-1-6-2003-1-10
2003-1-13-2003-1-17
.
.
.
2003-7-28-2003-8-1
2003-8-4-2003-8-8
.
.
2003-12-22-2003-12-26
注意:这里所指的周为工作日,起始日期为星期一,终止日期为星期五
先不考虑跨年的周工作日,只考虑本年纯周工作日。
...全文
79 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
yhb72 2003-08-04
  • 打赏
  • 举报
回复
艾,看你写的这么辛苦,散分了!
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
注意第一行。
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
呵呵,参数范围写错了而已。
你再比较看看。
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
<select name="workdays">
<%
for i= 1 to 12
if i=1 or i=3 or i=5 or i=7 or i=8 or i=10 or i=12 then

if tempoption<>"" then
else
tempoption=""
end if

for j=1 to 31
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=2 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=6 then
if tempoption="" then
tempoption=year(date())&"-"&"1"&"-"&"1"&"-"&tempdate
else
tempoption=tempoption&"-"&tempdate
end if
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if


next
end if

if i=4 or i=6 or i=9 or i=11 then
for j=1 to 30
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=2 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=6 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
else


if i=2 then
if (year(date()) mod 4) =0 then
for j=1 to 29
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=2 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=6 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
else
for j=1 to 28
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=2 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=6 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
end if
end if
end if
next

%>
</select>
yhb72 2003-08-03
  • 打赏
  • 举报
回复
这个问题我已经自己搞定了,代码给大家分享一下吧!
<select name="workdays">
<%
dim beginDate,myWeek,myDate,n
nowyear=year(date)
beginDate=nowyear&"-01-01"
endDate=nowyear&"-12-31"
totweeknum=DatePart("ww",endDate,vbMonday,vbFirstFullWeek)
for myWeek=1 to totweeknum
n=weekday(beginDate,vbMonday)
myDate=DateAdd("d",myWeek*7,beginDate)
selectlist=DateAdd("d",n-5,myDate)&"--"&DateAdd("d",5-n,myDate)
%>
<option><%=selectlist%></option>
<%
next
%>
</select>
够精炼的吧!
zorou_fatal(Red Star Over China你运行一下我的这段代码再和你的代码比较一下,你就知道有什么不同了,也就不会晕了!不过在此还是向你表示感谢!
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
晕,你说的到底是什么意思?
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
可以满足要求。
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
修改一下。
<select name="workdays">
<%
for i= 1 to 12
if i=1 or i=3 or i=5 or i=7 or i=8 or i=10 or i=12 then

if tempoption<>"" then
else
tempoption=""
end if

for j=1 to 31
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=1 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=5 then
if tempoption="" then
tempoption=year(date())&"-"&"1"&"-"&"1"&"-"&tempdate
else
tempoption=tempoption&"-"&tempdate
end if
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if


next
end if

if i=4 or i=6 or i=9 or i=11 then
for j=1 to 30
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=1 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=5 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
else


if i=2 then
if (year(date()) mod 4) =0 then
for j=1 to 29
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=1 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=5 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
else
for j=1 to 28
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=1 then
tempoption=tempdate
end if
if weekday(tempdate,vbUseSystem)=5 then
tempoption=tempoption&"-"&tempdate
%>
<option><%=tempoption%></option>
<%
tempoption=""
end if
next
end if
end if
end if
next

%>
</select>
zorou_fatal 2003-08-03
  • 打赏
  • 举报
回复
没有算入传统的节日和法定节日,可以自己加。
<select name="workdays">
<%
for i= 1 to 12
if i=1 or i=3 or i=5 or i=7 or i=8 or i=10 or i=12 then
for j=1 to 31
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=6 or weekday(tempdate,vbUseSystem)=7 then
else
%>
<option><%=tempdate%></option>
<%
end if
next
end if

if i=4 or i=6 or i=9 or i=11 then
for j=1 to 30
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=6 or weekday(tempdate,vbUseSystem)=7 then
else%>
<option><%=tempdate%></option>
<%
end if
next
else


if i=2 then
if (year(date()) mod 4) =0 then
for j=1 to 29
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=7 or weekday(tempdate,vbUseSystem)=6 then
else
%>
<option><%=tempdate%></option>
<%
end if
next
else
for j=1 to 28
tempdate=year(date())&"-"&i&"-"&j
if weekday(tempdate,vbUseSystem)=7 or weekday(tempdate,vbUseSystem)=6 then
else
%>
<option><%=tempdate%></option>
<%
end if
next
end if
end if
end if
next

%>
</select>
yhb72 2003-08-03
  • 打赏
  • 举报
回复
接近了,但还不完全符合我提出来的要求。希望大家继续努力啊!

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧