Solved

How to get the number of week by program

Posted on 2012-03-13
3
277 Views
Last Modified: 2012-03-28
Dear all experts,

I'm looking for a function which is used to get the number of week for specific date, for example.

If I enter 14 Mar 2012 in this function, it will return week 3
If I enter  6 Apr 2012 in this function, it will return week 2

This script will be deployed to an Access or Excel application.  Please kindly advise, thanks.
0
Comment
Question by:towo2002
[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
3 Comments
 
LVL 48

Expert Comment

by:Martin Liss
ID: 37715824
0
 
LVL 3

Expert Comment

by:Frank White
ID: 37715850
The following page explaining week numbers in Excel VBA might prove helpful: Week Numbers In Excel

Otherwise, you could use parsing using the Day() and Weekday() functions, counting how many days from day 1 of the month to the entered day match the "start of a week".
0
 
LVL 8

Accepted Solution

by:
Wiesje earned 300 total points
ID: 37719554
Week numbers are a complicated matter - but only because there are so many different ways to calculate the beginning of the first week.

For a previous question I found the following site: http://www.cpearson.com/excel/WeekNumbers.aspx

If the most standard week numbers is what you require you should use the solution from that question.

That is implementing the following function:
Public Function IsoWeekNumber(InDate As Date) As Long
    IsoWeekNumber = DatePart("ww", InDate, vbMonday, vbFirstFourDays)
End Function

And using it in your code as follows:
IsoWeekNumber(aDate)

Where aDate is a of course a Date type.
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

696 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