Get weeknumbers from a given date in ASP.

M

MONO

Hello!

I´m trying to get the weeknumber fom a given date but at some dates
will return the wrong weeknumber.

WeekNumber = DatePart("ww", TodayAsDate, vbMonday, vbFirstFourDays)

like 2003-12-27

I know that this is a Microsoft bug but i have tried their soultion
http://support.microsoft.com:80/support/kb/articles/q200/2/99.asp

but still it will return strange weeknumbers at some dates.


I want the output in weeks from 1 - 52 and every week starts with a
Monday.

Does anyone have a good function to output the weeknumbers from
a given date?


Micke
 
B

Bob Barrows

You cannot avoid having some dates return 53 as the week number. Think about
it. Using your definition, any year where 1-Jan is a Monday will have 53
weeks . What week number should 12/31/2001 return?

Try this script so you see the problem:
<%
dim d, i
d=#1/1/2001#
do until weekday(d) = vbMonday
d=dateadd("d",1,d)
loop
i=1
do until d > #1/1/2002#
Response.Write d & ": " & i & "<BR>"
d=dateadd("ww",1,d)
i = i + 1
loop
%>

Bob Barrows
 
M

MONO

Ohoooo, I´ve got major meltdown in my brain. I don´t know what i was
thinking about. Everthing is working fine.

Thanks for helping me think :)
/mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,906
Latest member
SkinfixSkintag

Latest Threads

Top