Solved

How to get the number of week by program

Posted on 2012-03-13
3
257 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 45

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 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

13 Experts available now in Live!

Get 1:1 Help Now