LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

如何得到今天是这个月的第几周

admin
2010年6月27日 17:40 本文热度 6622
[align=left]

思路是找出该月1号是星期几,推出该周的周末是几号,把两个值放入一个二维数组,依此推出下面几周的起始号和结束号,然后把所在取的号比较得出所在周
<-%
'///////////////////////////////////////////
'function:getweek(date)
'description:取得该日期所在月份的当前周
'para:date要计算的日期
'return:所在周数
'author:愚人(yurensky@hotmail.com)
'//////////////////////////////////////////

function getweek(strdate)
dim strmon,stryear,nweek

strdate = formatdatetime(strdate,2)
strmon = month(strdate)
stryear = year(strdate)
strday = day(strdate)
nweek = weekday(formatdatetime(stryear&"-"&strmon&"-1",2)) - 1

dim arrrange(5,2)

for i = 0 to 4
if i = 0 then
arrrange(i,0) = 1
if nweek = 6 then
arrrange(i,1) = arrrange(i,0)
else
arrrange(i,1) = arrrange(i,0) + 6 - nweek
end if
else
arrrange(i,0) = arrrange(i-1,1)+1
arrrange(i,1) = arrrange(i,0) + 6
end if
next

dim currweek

for i = 0 to 4
if arrrange(i,0) <= strday and strday <= arrrange(i,1) then
currweek = i + 1
end if
next

if currweek = "" then
currweek = 0
end if

getweek = currweek
end function


'test
dim nweek,cdate
cdate = now()
nweek = getweek(cdate)

response.write cdate & "是"&year(cdate) &"年"&month(cdate)&"月的第"&nweek&"周"
%->

另外一个思路:
<-script type="text/vbs"->
month_week=int(datepart("ww",now)-((datepart("y",now)-datepart("d",now))/7))
alert(month_week)
'datepart("ww",now) 现在是一年第多少周
'(datepart("y",now) 现在是一年第多少天
'datepart("d",now) 现在是这个月第多少天
'年的天数减这个月的天数 除上7就是这个月之前的周数
'总的周数-上个月的周数,表示今天是这个月的多少周
'如果有问题,请高手指点
<-/script->

另一个方法:
<-script type="text/vbs"->
dim month_week
month_week = datediff("ww", dateadd("d",-datepart("d",now), now), now)
'dateadd("d",-datepart("d",now), now) '上个月的月未 与今天对比
alert(month_week)
<-/script->

[/align]

该文章在 2010/6/27 17:40:05 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved