?
Solved

How do I determine what week in a month that a date falls?

Posted on 2010-01-05
3
Medium Priority
?
271 Views
Last Modified: 2012-05-08
I want to pass two dates to a function, the first date being a birth date and the second being the month in the current year. I would like it to be able to tell me which week in the second date that the birthday will fall.

Can I get some guidance?
0
Comment
Question by:SheldonC
  • 2
3 Comments
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 1000 total points
ID: 26180449
Public Shared Function GetWeekNumber(ByVal dtPassed As DateTime) As Integer
   
   
    Dim ciCurr As CultureInfo = CultureInfo.CurrentCulture
   
    Dim weekNum As Integer = ciCurr.Calendar.GetWeekOfYear(dtPassed, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
   
       
    Return weekNum
End Function
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 26180475
why do u need month in the current year if u pass the birthdate?
0
 

Author Comment

by:SheldonC
ID: 26181132
lol true I did not stop to think of that this function you sent works fine. Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month17 days, 11 hours left to enroll

830 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