Week number calculation

H

Henning

I am at ny ends wit, trying to figure out how to calculate
the current week number in current year and display the
result in an unbound tect box on a form.

I have tried the following
=weeknum(now(),2)
but it wil not work.

I am running access 2000 on an XP machine.

Any bright spark will be appriciated.

Henning
 
B

Bruce M. Thompson

I am at ny ends wit, trying to figure out how to calculate
the current week number in current year and display the
result in an unbound tect box on a form.

I have tried the following
=weeknum(now(),2)
but it wil not work.

I am running access 2000 on an XP machine.

Try:

=datepart("ww",date())
 
F

fredg

I am at ny ends wit, trying to figure out how to calculate
the current week number in current year and display the
result in an unbound tect box on a form.

I have tried the following
=weeknum(now(),2)
but it wil not work.

I am running access 2000 on an XP machine.

Any bright spark will be appriciated.

Henning

=DatePart("ww",Date())
 
P

Peter Hoyle

=DatePart("w",Date(),2,2)

The first number indicates the first day of the week - use 1 for Sunday, 2
for Monday etc.
The second number indicates the first week of the year.
1 = Start with week in which January 1 occurs (default).
2 = Start with the first week that has at least four days in the new year -
European Default

Cheers,
dullish spark!
 
M

Mike Sherrill

I am at ny ends wit, trying to figure out how to calculate
the current week number in current year and display the
result in an unbound tect box on a form.

I have tried the following
=weeknum(now(),2)
but it wil not work.

This is the most generally reliable VBA expression for determining the
week number according to ISO standards. Specify all the optional
parameters to make sure user settings don't trip you up.

CInt(Format(TheDate, "ww", vbMonday, vbFirstFourDays))

Unfortunately, a bug makes Format() return the wrong value for some
days; 29 Dec 2003, for example. A description of the bug
is in KB article Q200299, "Format or DatePart Functions Can Return
Wrong Week Number". That article includes a function that works
correctly (according to ISO 8601).

Using a table instead of a function might make your application more
useful. A table containing the week numbers for every day for the
next 100 years would have less than 37,000 rows. It can be used
directly by any client software, not just Access. And using a table
makes it dead simple to determine the dates covered by a given week
number.
 

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