Solved

Get the week number in the month

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 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

16 Experts available now in Live!

Get 1:1 Help Now