Solved

How to get the number of week by program

Posted on 2012-03-13
3
265 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
3 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 37715824
0
 
LVL 3

Expert Comment

by:DaFranker
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

773 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