Solved

Get the week number in the month

Posted on 2004-08-16
5
404 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 125 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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