Returning a date based on weeknumber

J

Jesper

Hi MVP's And Sesons Greatings to All !


Need som help on this problem!
I have i UserForm in wich i enter á weeknumber, e.g.
current weeknumber. What i need is excel to return the
date of monday in the specified week, in a field in my
UserForm, in order to use the date for further actions.
Now, i don't want to use a cell to perform the
calculation, but strictly use the VBA code to handle the
matter.
Any suggestions?....Well I thank you all in advance, and
wish you all a merry christmas and a happy new year !*S*

Best to U All.. Jesper- Denmark
 
N

Norman Harker

Hi Jesper!

In any week number problem of whatever nature it is crucial to
establish your definitions of:



· What day of the week a week starts on, and

· How is the first day of the first week determined.



For a discussion on Week numbers generally see:



Chip Pearson:

http://www.cpearson.com/excel/weeknum.htm



The major difficulty is alternative algorithms for determining the
first day of week one and for determining what day a week starts on.
Here are various systems and / requirements that all produce their own
solutions.



1. The Analysis ToolPak WEEKNUM function allows two bases. Both
provide for Jan-1 as being the first day of week number 1 with the two
alternatives providing that Sunday (Alternative 1) or Monday
(Alternative 2) being the first day of all subsequent weeks.

2. We can also use a simple formula for calculating week numbers
where Jan-1 is defined as the first day of week one and all subsequent
weeks starting 7 days later.

3. There are formulas and functions for calculating week numbers
where the ISO8601:2000 algorithm is used. Monday is regarded as the
first day of the week with week 1 starting on the Monday of the week
containing Jan-4.

4. Financial Year based systems where the financial year might
start on a given date.

5. Special requirements such as fixed weekly cycles (e.g. 4
weeks, 13 weeks etc). Such requirements need to specify the base date
and what day the week starts.

6. Term / Semester week numbering. Here we have "gross" systems
that include mid-term / mid-semester breaks and "net" systems which
exclude those weeks.

7. Month week numbering systems where the 1st of the month is
the first day of the first week and the fifth week is just an odd days
week.

8. Month week numbering systems where the first week starts on
the first Monday or Sunday of a Month and overlaps the subsequent
month.

9. Other bases limited only by the ingenuity of people who
devise systems (perhaps without considering whether the above
alternatives might be easier for all concerned).



Once we have you week numbering basis we can then set to work to find
the Monday of the week number you have.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.

Hi MVP's And Sesons Greatings to All !


Need som help on this problem!
I have i UserForm in wich i enter á weeknumber, e.g.
current weeknumber. What i need is excel to return the
date of monday in the specified week, in a field in my
UserForm, in order to use the date for further actions.
Now, i don't want to use a cell to perform the
calculation, but strictly use the VBA code to handle the
matter.
Any suggestions?....Well I thank you all in advance, and
wish you all a merry christmas and a happy new year !*S*

Best to U All.. Jesper- Denmark
 
P

Peo Sjoblom

Since Jesper is Danish I am sure he uses the ISO, here's one formula

=7*A1+DATE(B1,1,3)-WEEKDAY(DATE(B1,1,3))-5

where A1 holds the weeknumber and B1 the year, if current year change B1 to
TODAY()
one might want to check for entries in A1 (and B1 if today() is not used)
with and if function

in Danish

=7*A2+DATO(B2;1;3)-UGEDAG(DATO(B2;1;3))-5)
 
N

Norman Harker

Interesting Peo!

Has Denmark adopted the ISO:2000? I'm not so much interested in week
numbering but date representation yyyy-mm-dd.

Also it's getting quite important that Excel should have an ISO week
numbering function.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
P

Peo Sjoblom

Hi Norman,

I don't know about ISO:2000, I just know all Scandinavian countries are
using ISO
and I agree that there should be a ISO week function and all countries
should use metric <g>
 
N

Norman Harker

Hi Peo!

"all countries should use metric" <g>

Interesting about ISO adoption. Metric? I can't imagine any Anglo
Saxon culture accepting a French system <g>

There seems little point in supporting the ISO if we don't follow
agreements. In ISO2000 case I believe that there was no dissent.

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
news:[email protected]...
 
N

Norman Harker

Hi Peo!

Metrication was a big thing with the UK in the early 70's but they
then stopped as a result of fairly widespread public opposition. They
now have a mixed system but I'm not sure as to what changes are now
proposed. Last time I was there, I was still buying pints of beer and
paying exorbitant prices for gallons (Imperial) of petrol and the road
signs measured miles.

We're pretty much all metric in Australia although there is at least
one pub in Sydney (The Lord Nelson) that sells home brewed beer by the
pint.

It took 343 years before the entire World accepted the Gregorian
calendar reform (1582 - 1926 (Turkey)). I don't hold out much hope of
seeing ISO weeknumber or date representation in my lifetime. And I'd
still prefer it if my beer was sold in a pint mug!

--
Regards
Norman Harker MVP (Excel)
Sydney, Australia
(e-mail address removed)
Excel and Word Function Lists (Classifications, Syntax and Arguments)
available free to good homes.
 
P

Peo Sjoblom

Hi Norman,

in Sweden we switched from driving on the left side to driving on the right
side over one night..
 
H

Harlan Grove

Peo Sjoblom said:
in Sweden we switched from driving on the left side to driving on the right
side over one night..
....

And a very good thing everyone switched at the same time, no?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top