每个月的倒数第二周和上周的数据 [英] the penultimate week and last week of data for each month

查看:247
本文介绍了每个月的倒数第二周和上周的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在每个给定月份的最后2周返回数据

在Javascript中,但是有2种格式。


所以,倒数第二个一周(周一到周日)和最后一周(周一

到??)


我不确定是否可以完成,但所有帮助欢迎。


例如我有十二月,并希望看到最近两周..所以这个

并不意味着过去15天。我的意思是......


有时一个星期会越过2个月,它会在星期二结束,并在周三开始,就像以2004年11月为例。


2004年11月的例子,意味着11月有5个星期..

所以我想看看里面的数据第4周(周一至周日)

和第5周(周一至周二)。当然每年

年。

这可能吗?


我期待听到您的想法。

SimonC

解决方案

" SimonC" < SI ****** @ yahoo.co.uk>在消息中写道

news:11 ********************** @ z14g2000cwz.googlegr oups.com ...

我想用Javascript中的每个给定月份的最后2周返回数据,但是有2种格式。

所以,倒数第二周(周一到周日)和上周(星期一
到了??)

我不确定是否可以做到,但欢迎所有帮助。

例如我有12月,并希望看到最近2周..所以这
并不意味着过去15天。我的意思是......

有时一个星期将跨越2个月,它将于星期二结束,并于周三开始,例如2004年11月。

在2004年11月的例子中,意味着11月有5个星期......
所以我希望在第4周(周一至周日)和第5周内看到数据(周一至周二)。当然对于
年的每个月。
这可能吗?

我期待听到你的想法。
SimonC



这会有帮助吗?请注意自动换行。


选项明确

''*

''*声明常数

''*

Const cVBS =" penuweek.vbs"

Const cYER = 2004

''*

''*声明变量

''*

Dim arrDAT(12,1)

Dim intDAT

Dim strDAT

Dim intDOW

Dim intMON

Dim stryER

strYER = cYER

''*

''* 12个月

''*

对于intMON = 1到12

''*

''*下个月的第一天

''*

strDAT = DateSerial(strYER,intMON + 1, 1)

''*

''*本月最后一天

''*

strDAT = DateAdd(" d", - 1,strDAT)

''*

''*星期几

''*

intDOW = DatePart(" w",strDAT,2)

''*

''*星期一之前的日期st $ / $
''*

如果intDOW = 1则intDOW = 8

intDAT =(intDOW + 6)* -1

strDAT = DateAdd(" d",intDAT,strDAT)

arrDAT(intMON,0)= strDAT

''*

''*周日两周后的日期

''*

strDAT = DateAdd(" d",13,strDAT)

arrDAT(intMON,1)= strDAT

下一页

''*

''*结果

' '*

strDAT =""

对于intMON = 1到12

strDAT = strDAT& intMON& " ;.

strDAT = strDAT& arrDAT(intMON,0)& " :"

strDAT = strDAT& arrDAT(intMON,1)& vbCrLf

下一页

MsgBox strDAT,vbInformation,cVBS


McKirahan写道:

" SimonC" < SI ****** @ yahoo.co.uk>在消息中写道
新闻:11 ********************** @ z14g2000cwz.googlegr oups.com ......

我想在Javascript中返回每个给定月份最后2周的数据,但是有2种格式。


[...]
这是救命?请注意自动换行。


由于这是一个JavaScript论坛,并且OP明确要求

JavaScript,为什么会''这个''帮助?

选项明确
''*
''*声明常数



[...]


也许如果你用适当的语言重写它...


-

Zif


" Zifud" <滋*** @ hotmail.com.com>在留言中写道

news:41 ********************** @ per-qv1-newsreader-01.iinet.net.au ...

McKirahan写道:

" SimonC" < SI ****** @ yahoo.co.uk>在消息中写道
新闻:11 ********************** @ z14g2000cwz.googlegr oups.com ......

我想在Javascript中返回每个给定月份最后2周的数据,但是有两种格式。


[...]


这会有帮助吗?请注意自动换行。



由于这是一个JavaScript论坛,并且OP明确要求使用JavaScript,为什么这个有帮助?

选项明确
''*
''*声明常数


[...]

也许如果你用适当的语言重写它......

Zif




OP确实问过是这可能吗? - 这个 (至少)表明它是......

你当然是对的。我发布到多个小组,有时当我想到解决方案时,我忘记将其自定义为小组。


I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.

So, the penultimate week (Monday to Sunday) and the last week (Monday
to ??)

I''m not sure if it can be done, but all help welcomed.

E.g. I have December and would like to see the last 2 weeks.. So this
doesnt mean the last 15 days. What i mean by this is...

Sometimes a Week will cross over into 2 months, where it finishes on
Tuesday and starts on Wednesday, like November 2004 for example.

With the November 2004 example, means there are 5 weeks in November..
so i would like to see the data within the 4th week (Monday to Sunday)
and the 5th week (Monday to Tuesday). Of course for every month of the
year.
Is this possible??

I look forward to hearing your thoughts.
SimonC

解决方案

"SimonC" <si******@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.

So, the penultimate week (Monday to Sunday) and the last week (Monday
to ??)

I''m not sure if it can be done, but all help welcomed.

E.g. I have December and would like to see the last 2 weeks.. So this
doesnt mean the last 15 days. What i mean by this is...

Sometimes a Week will cross over into 2 months, where it finishes on
Tuesday and starts on Wednesday, like November 2004 for example.

With the November 2004 example, means there are 5 weeks in November..
so i would like to see the data within the 4th week (Monday to Sunday)
and the 5th week (Monday to Tuesday). Of course for every month of the
year.
Is this possible??

I look forward to hearing your thoughts.
SimonC



Will this help? Watch for word-wrap.

Option Explicit
''*
''* Declare Constants
''*
Const cVBS = "penuweek.vbs"
Const cYER = 2004
''*
''* Declare Variables
''*
Dim arrDAT(12,1)
Dim intDAT
Dim strDAT
Dim intDOW
Dim intMON
Dim strYER
strYER = cYER
''*
''* 12 Months
''*
For intMON = 1 To 12
''*
''* First day of next month
''*
strDAT = DateSerial(strYER,intMON+1,1)
''*
''* Last day of this month
''*
strDAT = DateAdd("d",-1,strDAT)
''*
''* Day of week
''*
intDOW = DatePart("w",strDAT,2)
''*
''* Date of Monday before last
''*
If intDOW = 1 Then intDOW = 8
intDAT = (intDOW + 6) * -1
strDAT = DateAdd("d",intDAT,strDAT)
arrDAT(intMON,0) = strDAT
''*
''* Date of Sunday two weeks later
''*
strDAT = DateAdd("d",13,strDAT)
arrDAT(intMON,1) = strDAT
Next
''*
''* Results
''*
strDAT = ""
For intMON = 1 To 12
strDAT = strDAT & intMON & ". "
strDAT = strDAT & arrDAT(intMON,0) & " : "
strDAT = strDAT & arrDAT(intMON,1) & vbCrLf
Next
MsgBox strDAT,vbInformation,cVBS


McKirahan wrote:

"SimonC" <si******@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.

[...]
Will this help? Watch for word-wrap.

Since this is a JavaScript forum, and the OP has explicitly asked for
JavaScript, why would ''this'' help?
Option Explicit
''*
''* Declare Constants


[...]

Perhaps if you re-write it in an appropriate language...

--
Zif


"Zifud" <zi***@hotmail.com.com> wrote in message
news:41**********************@per-qv1-newsreader-01.iinet.net.au...

McKirahan wrote:

"SimonC" <si******@yahoo.co.uk> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

I would like to return data from the last 2 weeks of each given month
in Javascript, but in 2 formats.


[...]


Will this help? Watch for word-wrap.



Since this is a JavaScript forum, and the OP has explicitly asked for
JavaScript, why would ''this'' help?

Option Explicit
''*
''* Declare Constants


[...]

Perhaps if you re-write it in an appropriate language...

--
Zif



The OP did ask "Is this possible??" -- "this" (at least) shows that it is...
You''re right, of course. I post to multiple groups and sometimes when I
think of a solution I forget to customize it to the group.


这篇关于每个月的倒数第二周和上周的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆