Solved

Get the week number in the month

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now