Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Get the week number in the month

Posted on 2004-08-16
5
Medium Priority
?
408 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:   The Exchange of informatio…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

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