Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get the week number in the month

Posted on 2004-08-16
5
Medium Priority
?
409 Views
Last Modified: 2012-05-05
I need a function that will take todays date (using Now()) and get the week number of the month. I cant seem to figure it out.

Example:

strWeek = WeekNumber(Now()) 'Function to get the week number

strWeek returns 3 since this is the 3rd week of the month.

Thanks
0
Comment
Question by:MadDog986
5 Comments
 
LVL 6

Expert Comment

by:casstd
ID: 11816810
Hi,

         Here is the code  Response.write WeekDay(Date()). This returns 3.

You can look at this site for various date functions.

http://www.ronshardwebapps.com/tips/jantutorialtimedate.asp
0
 

Author Comment

by:MadDog986
ID: 11817648
I just tried that and it returns 2, not 3.
0
 
LVL 4

Expert Comment

by:Tasneem
ID: 11817997
it does return 3. Check your system date and month and year.
0
 
LVL 7

Accepted Solution

by:
j2nku earned 500 total points
ID: 11818934
Function Weeknumber(idate)
  if not isdate(idate) Then idate = date()
  monthweek = DatePart("WW",DateSerial(Year(idate),Month(idate),1))
  nowweek = DatePart("WW",idate)
  Weeknumber = nowweek - monthweek + 1
End Function

And then you can just do:

Response.Write Weeknumber(now)

Try this
0
 

Author Comment

by:MadDog986
ID: 11824776
Thank you! Just what i wanted.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question